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 #ifndef _MTP_HTTP_H_
00037 #define _MTP_HTTP_H_
00038
00042 enum http_status_code_e
00043 {
00044
00045 CONTINUE=100,
00046 SWITCHING_PROTOCOLS,
00047 PROCESSING,
00048
00049 OK=200,
00050 CREATED,
00051 ACCEPTED,
00052 NON_AUTHORITATIVE_INFORMATION,
00053 NO_CONTENT,
00054 RESET_CONTENT,
00055 PARTIAL_CONTENT,
00056 MULTI_STATUS,
00057
00058 BAD_REQUEST=400,
00059 UNAUTHORIZED,
00060 PAYMENT_REQUIRED,
00061 FORBIDDEN,
00062 NOT_FOUND,
00063 METHOD_NOT_ALLOWED,
00064 NOT_ACCEPTABLE,
00065 PROXY_AUTHENTICATION_REQUIRED,
00066 REQUEST_TIMEOUT,
00067 CONFLICT,
00068 GONE,
00069 LENGTH_REQUIRED,
00070 PRECONDITION_FAILED,
00071 REQUST_ENTITY_TOO_LARGE,
00072 REQUEST_URI_TOO_LONG,
00073 UNSUPPORTED_MEDIA_TYPE,
00074 REQUESTED_RANGE_NOT_SATISFIABLE,
00075 EXPECTATION_FAILED,
00076 UNPROCESSABLE_ENTITY,
00077 LOCKED,
00078 FAILED_DEPENDANCY,
00079 UNORDERED_COLLECTION,
00080 UPGRADE_REQUIRED,
00081 RETRY_WITH
00082 };
00083
00087 enum http_performative_e
00088 {
00089 HTTP_PERFORMATIVE_UNDEF=-1,
00090 HTTP_PERFORMATIVE_ZERO=0,
00091 HTTP_HEAD,
00092 HTTP_GET,
00093 HTTP_POST,
00094 HTTP_PUT,
00095 HTTP_DELETE,
00096 HTTP_TRACE,
00097 HTTP_OPTIONS,
00098 HTTP_CONNECT,
00099 HTTP_NUM_PERFORMATIVES
00100 };
00101
00102 typedef struct mtp_http_content_s
00103 {
00104 char* content_type;
00105 void* data;
00106 } mtp_http_content_t;
00107
00108 typedef struct mtp_http_s
00109 {
00110 enum http_status_code_e http_status_code;
00111 enum http_performative_e http_performative;
00112 char* http_version;
00113 char* host;
00114 char* return_code;
00115 char* target;
00116
00117 char* date;
00118 char* server;
00119 char* accept_ranges;
00120 char* content_length;
00121 char* connection;
00122 char* content_type;
00123 char* user_agent;
00124
00125 char* cache_control;
00126 char* mime_version;
00127
00128
00129
00130 int message_parts;
00131 char* boundary;
00132 struct mtp_http_content_s* content;
00133 } mtp_http_t;
00134 typedef mtp_http_t* mtp_http_p;
00135
00145 const char* http_GetExpression(const char* string, char** expr);
00146
00160 int http_ParseExpression(
00161 const char* expression_string,
00162 char** name,
00163 char** value
00164 );
00165
00166 const char* http_ParseHeader(
00167 mtp_http_p http,
00168 const char* string
00169 );
00170
00171 const char*
00172 http_GetToken(const char* string, char** token);
00173
00174 int
00175 mtp_http_Destroy(mtp_http_p http);
00176
00177 struct connection_s;
00178 int
00179 mtp_http_InitializeFromConnection(struct mtp_http_s *http, struct connection_s *connection);
00180
00181 mtp_http_p
00182 mtp_http_New(void);
00183
00184 struct connection;
00185 int
00186 mtp_http_Parse(struct mtp_http_s* http, const char* string);
00187
00188 struct message_s;
00189 int
00190 mtp_http_ComposeMessage(struct message_s* message);
00191
00192 struct message_s*
00193 mtp_http_CreateMessage(
00194 mtp_http_t* mtp_http,
00195 char* hostname,
00196 int port );
00197 #endif