00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 #ifndef _MTP_HTTP_H_
00040 #define _MTP_HTTP_H_
00041 
00045 enum http_status_code_e
00046 {
00047   
00048   CONTINUE=100,
00049   SWITCHING_PROTOCOLS,
00050   PROCESSING,
00051   
00052   OK=200,
00053   CREATED,
00054   ACCEPTED,
00055   NON_AUTHORITATIVE_INFORMATION,
00056   NO_CONTENT,
00057   RESET_CONTENT,
00058   PARTIAL_CONTENT,
00059   MULTI_STATUS,
00060   
00061   BAD_REQUEST=400,
00062   UNAUTHORIZED,
00063   PAYMENT_REQUIRED,
00064   FORBIDDEN,
00065   NOT_FOUND,
00066   METHOD_NOT_ALLOWED,
00067   NOT_ACCEPTABLE,
00068   PROXY_AUTHENTICATION_REQUIRED,
00069   REQUEST_TIMEOUT,
00070   CONFLICT,
00071   GONE,
00072   LENGTH_REQUIRED,
00073   PRECONDITION_FAILED,
00074   REQUST_ENTITY_TOO_LARGE,
00075   REQUEST_URI_TOO_LONG,
00076   UNSUPPORTED_MEDIA_TYPE,
00077   REQUESTED_RANGE_NOT_SATISFIABLE,
00078   EXPECTATION_FAILED,
00079   UNPROCESSABLE_ENTITY,
00080   LOCKED,
00081   FAILED_DEPENDANCY,
00082   UNORDERED_COLLECTION,
00083   UPGRADE_REQUIRED,
00084   RETRY_WITH
00085 };
00086 
00090 enum http_performative_e
00091 {
00092   HTTP_PERFORMATIVE_UNDEF=-1,
00093   HTTP_PERFORMATIVE_ZERO=0,
00094   HTTP_HEAD,
00095   HTTP_GET,
00096   HTTP_POST,
00097   HTTP_PUT,
00098   HTTP_DELETE,
00099   HTTP_TRACE,
00100   HTTP_OPTIONS,
00101   HTTP_CONNECT,
00102   HTTP_RESPONSE,
00103   HTTP_NUM_PERFORMATIVES
00104 };
00105 
00106 typedef struct mtp_http_content_s
00107 {
00108   char* content_type;
00109   void* data;
00110 } mtp_http_content_t;
00111 
00112 typedef struct mtp_http_s
00113 {
00114   enum http_status_code_e http_status_code;
00115   enum http_performative_e http_performative;
00116   char* http_version;
00117   char* host;
00118   char* return_code;
00119   char* target;       
00120 
00121   char* date;
00122   char* server;
00123   char* accept_ranges;
00124   char* content_length;
00125   char* connection;
00126   char* content_type;
00127   char* user_agent;
00128 
00129   char* cache_control;
00130   char* mime_version;
00131 
00132   
00133   int response_code;
00134   char* response_string;
00135 
00136   
00137   
00138   int message_parts;
00139   char* boundary;
00140   struct mtp_http_content_s* content;
00141 
00142   
00143   int header_length;
00144 } mtp_http_t;
00145 typedef mtp_http_t* mtp_http_p;
00146 
00147 #define SOCKET_INPUT_SIZE 4096
00148 
00158 const char* http_GetExpression(const char* string, char** expr);
00159 
00173 int http_ParseExpression(
00174     const char* expression_string,
00175     char** name,
00176     char** value
00177     );
00178 
00179 const char* http_ParseRequest(
00180     mtp_http_p http,
00181     const char* string
00182     );
00183 
00184 const char*
00185 http_GetToken(const char* string, char** token);
00186 
00187 int
00188 mtp_http_Destroy(mtp_http_p http);
00189 
00190 struct connection_s;
00191 int
00192 mtp_http_InitializeFromConnection(struct mtp_http_s *http, struct connection_s *connection);
00193 
00194 mtp_http_p 
00195 mtp_http_New(void);
00196 
00197 struct connection;
00198 const char* 
00199 mtp_http_ParseHeader(struct mtp_http_s* http, const char* string);
00200 
00201 int 
00202 mtp_http_Parse(struct mtp_http_s* http, const char* string);
00203 
00204 struct message_s;
00205 int 
00206 mtp_http_ComposeMessage(struct message_s* message);
00207 
00208 struct message_s* 
00209 mtp_http_CreateMessage(
00210     mtp_http_t* mtp_http,
00211     char* hostname,
00212     int port );
00213 #endif