(file) Return to httpcommon.h CVS log (file) (dir) Up to [OMI] / omi / http

  1 krisbash 1.1 /*
  2              **==============================================================================
  3              **
  4              ** Open Management Infrastructure (OMI)
  5              **
  6              ** Copyright (c) Microsoft Corporation
  7              ** 
  8              ** Licensed under the Apache License, Version 2.0 (the "License"); you may not 
  9              ** use this file except in compliance with the License. You may obtain a copy 
 10              ** of the License at 
 11              **
 12              **     http://www.apache.org/licenses/LICENSE-2.0 
 13              **
 14              ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15              ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
 16              ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
 17              ** MERCHANTABLITY OR NON-INFRINGEMENT. 
 18              **
 19              ** See the Apache 2 License for the specific language governing permissions 
 20              ** and limitations under the License.
 21              **
 22 krisbash 1.1 **==============================================================================
 23              */
 24              
 25              #ifndef _omi_http_httpcommon_h
 26              #define _omi_http_httpcommon_h
 27              
 28              #include <stddef.h>
 29              
 30              #include "config.h"
 31              #include <common.h>
 32              #include <base/batch.h>
 33              #include <base/interaction.h>
 34              #include <sock/selector.h>
 35              
 36              BEGIN_EXTERNC
 37              
 38              /* HTTP Error codes */
 39              #define HTTP_ERROR_CODE_OK                          200
 40              #define HTTP_ERROR_CODE_BAD_REQUEST                 400
 41              #define HTTP_ERROR_CODE_UNAUTHORIZED                401
 42              #define HTTP_ERROR_CODE_INTERNAL_SERVER_ERROR       500
 43 krisbash 1.1 #define HTTP_ERROR_CODE_NOT_SUPPORTED               501
 44              
 45              /*
 46              **==============================================================================
 47              **
 48              ** Define supported Authentication and other related fields.
 49              **
 50              **==============================================================================
 51              */
 52              #define AUTHENTICATION_BASIC            "Basic"
 53              #define AUTHENTICATION_BASIC_LENGTH     5 /*This is the length of "Basic"*/
 54              #define HTTP_WWWAUTHENTICATE_BASIC      "WWW-Authenticate: Basic realm=\"WSMAN\""
 55              
 56              /* ************************************************ */
 57              /*                  Datatypes                       */
 58              /* ************************************************ */
 59              typedef struct _Http Http;
 60              
 61              /* HTTP options.
 62                  mostly used for unit-testing; default values
 63                  are hard-coded but can be overwritten by 
 64 krisbash 1.1     unit-tests/config modules   */
 65              typedef struct _HttpOptions
 66              {
 67                  /* timeout for network delays and keep-alive;
 68                  note: http does not have timeout for server/provider processing */
 69                  MI_Uint64   timeoutUsec;
 70              
 71                  /* Enable tracing of HTTP input and output */
 72                  MI_Boolean enableTracing;
 73              }
 74              HttpOptions;
 75              
 76              /* Server_SSL_Options.
 77                  Allows SSLv2 or SSLv3 to be individually disabled, or to disable
 78                  both protocols, based on omiserver.conf. */
 79              typedef enum _Server_SSL_Options
 80              {
 81                  // Must be bits so these can be specified individually or together
 82                  DISABLE_SSL_V2 = 0x01,
 83                  DISABLE_SSL_V3 = 0x02
 84              }
 85 krisbash 1.1 Server_SSL_Options;
 86              
 87              //------------------------------------------------------------------------------------------------------------------
 88              
 89              /* 60 sec timeout */
 90              #define DEFAULT_HTTP_OPTIONS  { (60 * 1000000), MI_FALSE }
 91              
 92              MI_Result Http_New_Server(
 93                  _Out_       Http**              selfOut,
 94                  _In_        Selector*           selector,               /*optional, maybe NULL*/
 95                  _In_        unsigned short      http_port,              /* 0 to disable */
 96                  _In_        unsigned short      https_port,             /* 0 to disable */
 97                  _In_opt_z_  const char*         sslCipherSuite,         /* NULL to disable */
 98                  _In_        Server_SSL_Options  sslOptions,             /* 0 for default options */
 99                  _In_        OpenCallback        callbackOnNewConnection,
100                  _In_opt_    void*               callbackData,
101                  _In_opt_    const HttpOptions*  options );              /* Sets http options (mostly unit-test support) */
102              
103              MI_Result Http_Delete(
104                  Http* self);
105              
106 krisbash 1.1 MI_Result Http_Run(
107                  Http* self,
108                  MI_Uint64 timeoutUsec);
109              
110              //------------------------------------------------------------------------------------------------------------------
111              // Auxiliary methods
112              
113              MI_Boolean ParseAuthorization(
114                  _Inout_     HttpHeaders*    recvHeaders,
115                  _In_        CharPtr         value );
116              
117              void ParseContentType(
118                  _Inout_     HttpHeaders*    recvHeaders,
119                  _In_        CharPtr         value );
120                  
121              #ifdef CONFIG_POSIX
122              
123              char* GetSslErrorString(
124                  _Out_       char* buf,
125                  _In_        size_t bufLen);
126              
127 krisbash 1.1 #endif
128              
129              END_EXTERNC
130              
131              #endif /* _omi_http_httpcommon_h */

ViewCVS 0.9.2