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_RESPONSE,
00100 HTTP_NUM_PERFORMATIVES
00101 };
00102
00103 typedef struct mtp_http_content_s
00104 {
00105 char* content_type;
00106 void* data;
00107 } mtp_http_content_t;
00108
00109 typedef struct mtp_http_s
00110 {
00111 enum http_status_code_e http_status_code;
00112 enum http_performative_e http_performative;
00113 char* http_version;
00114 char* host;
00115 char* return_code;
00116 char* target;
00117
00118 char* date;
00119 char* server;
00120 char* accept_ranges;
00121 char* content_length;
00122 char* connection;
00123 char* content_type;
00124 char* user_agent;
00125
00126 char* cache_control;
00127 char* mime_version;
00128
00129
00130 int response_code;
00131 char* response_string;
00132
00133
00134
00135 int message_parts;
00136 char* boundary;
00137 struct mtp_http_content_s* content;
00138 } mtp_http_t;
00139 typedef mtp_http_t* mtp_http_p;
00140
00141 #define SOCKET_INPUT_SIZE 4096
00142
00152 const char* http_GetExpression(const char* string, char** expr);
00153
00167 int http_ParseExpression(
00168 const char* expression_string,
00169 char** name,
00170 char** value
00171 );
00172
00173 const char* http_ParseHeader(
00174 mtp_http_p http,
00175 const char* string
00176 );
00177
00178 const char*
00179 http_GetToken(const char* string, char** token);
00180
00181 int
00182 mtp_http_Destroy(mtp_http_p http);
00183
00184 struct connection_s;
00185 int
00186 mtp_http_InitializeFromConnection(struct mtp_http_s *http, struct connection_s *connection);
00187
00188 mtp_http_p
00189 mtp_http_New(void);
00190
00191 struct connection;
00192 int
00193 mtp_http_Parse(struct mtp_http_s* http, const char* string);
00194
00195 struct message_s;
00196 int
00197 mtp_http_ComposeMessage(struct message_s* message);
00198
00199 struct message_s*
00200 mtp_http_CreateMessage(
00201 mtp_http_t* mtp_http,
00202 char* hostname,
00203 int port );
00204 #endif