summaryrefslogtreecommitdiffstats
path: root/tinyHTTP/include/tinyhttp
diff options
context:
space:
mode:
Diffstat (limited to 'tinyHTTP/include/tinyhttp')
-rw-r--r--tinyHTTP/include/tinyhttp/auth/thttp_auth.h65
-rw-r--r--tinyHTTP/include/tinyhttp/auth/thttp_challenge.h75
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header.h105
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_Authorization.h77
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_Content_Length.h62
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_Content_Type.h76
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_Dummy.h62
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_ETag.h67
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Accept.h56
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Key.h56
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Protocol.h58
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Version.h58
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_Transfer_Encoding.h76
-rw-r--r--tinyHTTP/include/tinyhttp/headers/thttp_header_WWW_Authenticate.h82
-rw-r--r--tinyHTTP/include/tinyhttp/parsers/thttp_parser_header.h44
-rw-r--r--tinyHTTP/include/tinyhttp/parsers/thttp_parser_message.h44
-rw-r--r--tinyHTTP/include/tinyhttp/parsers/thttp_parser_url.h45
-rw-r--r--tinyHTTP/include/tinyhttp/thttp_action.h251
-rw-r--r--tinyHTTP/include/tinyhttp/thttp_dialog.h73
-rw-r--r--tinyHTTP/include/tinyhttp/thttp_event.h75
-rw-r--r--tinyHTTP/include/tinyhttp/thttp_message.h263
-rw-r--r--tinyHTTP/include/tinyhttp/thttp_proxy_node_plugin.h33
-rw-r--r--tinyHTTP/include/tinyhttp/thttp_session.h207
-rw-r--r--tinyHTTP/include/tinyhttp/thttp_url.h93
24 files changed, 2103 insertions, 0 deletions
diff --git a/tinyHTTP/include/tinyhttp/auth/thttp_auth.h b/tinyHTTP/include/tinyhttp/auth/thttp_auth.h
new file mode 100644
index 0000000..9b88ccc
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/auth/thttp_auth.h
@@ -0,0 +1,65 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+/**@file thttp_auth.h
+ * @brief HTTP basic/digest authetication (RFC 2617) implementations.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef TINYHTTP_THTTP_AUTH_H
+#define TINYHTTP_THTTP_AUTH_H
+
+#include "tinyhttp_config.h"
+
+#include "tsk_md5.h"
+#include "tsk_buffer.h"
+
+THTTP_BEGIN_DECLS
+
+typedef char nonce_count_t[9];
+typedef char thttp_auth_ws_keystring_t[255];
+#define THTTP_NCOUNT_2_STRING(nc_int32, nc_string) \
+ { \
+ tsk_size_t i = 7; \
+ do{ \
+ nc_string[7-i]= "0123456789abcdef"[(nc_int32 >> i*4) & 0xF]; \
+ } \
+ while(i--); \
+ nc_string[8] = '\0'; \
+ }
+
+TINYHTTP_API tsk_size_t thttp_auth_basic_response(const char* userid, const char* password, char** response);
+
+TINYHTTP_API int thttp_auth_digest_HA1(const char* username, const char* realm, const char* password, tsk_md5string_t* ha1);
+TINYHTTP_API int thttp_auth_digest_HA1sess(const char* username, const char* realm, const char* password, const char* nonce, const char* cnonce, tsk_md5string_t* ha1sess);
+
+TINYHTTP_API int thttp_auth_digest_HA2(const char* method, const char* url, const tsk_buffer_t* entity_body, const char* qop, tsk_md5string_t* ha2);
+
+TINYHTTP_API int thttp_auth_digest_response(const tsk_md5string_t *ha1, const char* nonce, const nonce_count_t noncecount, const char* cnonce,
+ const char* qop, const tsk_md5string_t* ha2, tsk_md5string_t* response);
+
+TINYHTTP_API tsk_size_t thttp_auth_ws_response(const char* key, thttp_auth_ws_keystring_t* response);
+
+THTTP_END_DECLS
+
+#endif /* TINYHTTP_THTTP_H */
diff --git a/tinyHTTP/include/tinyhttp/auth/thttp_challenge.h b/tinyHTTP/include/tinyhttp/auth/thttp_challenge.h
new file mode 100644
index 0000000..23596df
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/auth/thttp_challenge.h
@@ -0,0 +1,75 @@
+/*
+* Copyright (C) 2010-2015 Mamadou DIOP.
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_challenge.h
+ * @brief HTTP authentication challenge.
+ *
+ */
+#ifndef TINYHTTP_AUTHENTICATION_CHALLENGE_H
+#define TINYHTTP_AUTHENTICATION_CHALLENGE_H
+
+#include "tinyhttp_config.h"
+
+#include "tinyhttp/thttp_message.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+#include "tinyhttp/auth/thttp_auth.h"
+
+#include "tsk_object.h"
+#include "tsk_buffer.h"
+#include "tsk_list.h"
+#include "tsk_md5.h"
+
+THTTP_BEGIN_DECLS
+
+typedef struct thttp_challenge_s
+{
+ TSK_DECLARE_OBJECT;
+
+ tsk_bool_t isproxy;
+
+ char* scheme;
+ char* realm;
+ char* nonce;
+ char* opaque;
+ char* algorithm;
+ const char* qop;
+
+ tsk_md5string_t cnonce;
+ unsigned nc;
+}
+thttp_challenge_t;
+
+typedef tsk_list_t thttp_challenges_L_t;
+
+int thttp_challenge_update(thttp_challenge_t *self, const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop);
+thttp_header_t *thttp_challenge_create_header_authorization(thttp_challenge_t *self, const char* username, const char* password, const thttp_request_t *request);
+thttp_header_t *thttp_challenge_create_header_authorization_2(thttp_challenge_t *self, const char* username, const char* password, const char* method, const char *uristring, const tsk_buffer_t* entity_body);
+
+
+thttp_challenge_t* thttp_challenge_create(tsk_bool_t isproxy,const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop);
+thttp_challenge_t* thttp_challenge_dup(const thttp_challenge_t* self);
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_challenge_def_t;
+
+THTTP_END_DECLS
+
+#endif /* TINYHTTP_AUTHENTICATION_CHALLENGE_H */
+
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header.h b/tinyHTTP/include/tinyhttp/headers/thttp_header.h
new file mode 100644
index 0000000..0545ebf
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header.h
@@ -0,0 +1,105 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header.h
+ * @brief Defines a HTTP header (field-name: field-value).
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef TINYHTTP_HEADER_H
+#define TINYHTTP_HEADER_H
+
+#include "tinyhttp_config.h"
+
+#include "tsk_ragel_state.h"
+
+#include "tsk_params.h"
+#include "tsk_object.h"
+#include "tsk_safeobj.h"
+#include "tsk_memory.h"
+#include "tsk_string.h"
+#include "tsk_list.h"
+#include "tsk_buffer.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_HEADER(self) ((thttp_header_t*)(self))
+#define THTTP_HEADER_PARAMS(self) (THTTP_HEADER(self)->params)
+
+// FD
+struct thttp_header_s;
+
+typedef int (*thttp_header_value_tostring_f)(const struct thttp_header_s* header, tsk_buffer_t* output);
+#define THTTP_HEADER_VALUE_TOSTRING_F(self) ((thttp_header_value_tostring_f)(self))
+
+/**
+ * @enum thttp_header_type_e
+ *
+ * @brief List of all supported headers.
+**/
+typedef enum thttp_header_type_e
+{
+ thttp_htype_Authorization,
+ thttp_htype_Content_Length,
+ thttp_htype_Content_Type,
+ thttp_htype_Dummy,
+ thttp_htype_ETag,
+ thttp_htype_Proxy_Authenticate,
+ thttp_htype_Proxy_Authorization,
+ thttp_htype_Sec_WebSocket_Accept,
+ thttp_htype_Sec_WebSocket_Protocol,
+ thttp_htype_Sec_WebSocket_Key,
+ thttp_htype_Sec_WebSocket_Version,
+ thttp_htype_Transfer_Encoding,
+ thttp_htype_WWW_Authenticate,
+}
+thttp_header_type_t;
+
+/*================================
+*/
+typedef struct thttp_header_s
+{
+ TSK_DECLARE_OBJECT;
+ thttp_header_type_t type;
+ thttp_header_value_tostring_f tostring;
+ tsk_params_L_t *params;
+}
+thttp_header_t;
+
+#define THTTP_DECLARE_HEADER thttp_header_t __header__
+typedef tsk_list_t thttp_headers_L_t; /**< List of @ref thttp_header_t elements. */
+/*
+================================*/
+
+TINYHTTP_API const char *thttp_header_get_name(thttp_header_type_t type);
+TINYHTTP_API const char *thttp_header_get_nameex(const thttp_header_t *self);
+TINYHTTP_API char thttp_header_get_param_separator(const thttp_header_t *self);
+TINYHTTP_API int thttp_header_serialize(const thttp_header_t *self, tsk_buffer_t *output);
+TINYHTTP_API char* thttp_header_tostring(const thttp_header_t *self);
+TINYHTTP_API char* thttp_header_value_tostring(const thttp_header_t *self);
+
+THTTP_END_DECLS
+
+#endif /* TINYHTTP_HEADERS_H */
+
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_Authorization.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_Authorization.h
new file mode 100644
index 0000000..0543b5b
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_Authorization.h
@@ -0,0 +1,77 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_Authorization.h
+ * @brief HTTP header 'Authorization'.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef _THTTP_HEADER_AUTHORIZATION_H_
+#define _THTTP_HEADER_AUTHORIZATION_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+
+THTTP_BEGIN_DECLS
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// HTTP header 'Authorization' .
+///
+/// @par ABNF = Authorization = "Authorization" ":" credentials
+/// credentials = "Digest" digest-response
+/// digest-response = digest-response-value *(COMMA digest-response-value)
+/// digest-response-value = ( username / realm / nonce / digest-url / auth-response / [ algorithm ] / [cnonce] / [opaque] / [message-qop] / [nonce-count] / [auth-param] )
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct thttp_header_Authorization_s
+{
+ THTTP_DECLARE_HEADER;
+
+ char* scheme;
+ char* username;
+ char* realm;
+ char* nonce;
+ char* uri;
+ char* response;
+ char* algorithm;
+ char* cnonce;
+ char* opaque;
+ char* qop;
+ char* nc;
+}
+thttp_header_Authorization_t;
+typedef thttp_header_Authorization_t thttp_header_Proxy_Authorization_t;
+
+TINYHTTP_API thttp_header_Authorization_t *thttp_header_Authorization_parse(const char *data, tsk_size_t size);
+TINYHTTP_API thttp_header_Proxy_Authorization_t *thttp_header_Proxy_Authorization_parse(const char *data, tsk_size_t size);
+
+thttp_header_Authorization_t* thttp_header_authorization_create();
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Authorization_def_t;
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_AUTHORIZATION_H_ */
+
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_Content_Length.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_Content_Length.h
new file mode 100644
index 0000000..9d7b4a9
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_Content_Length.h
@@ -0,0 +1,62 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_Content_Length.h
+ * @brief HTTP header 'Content-Length'.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef _THTTP_HEADER_CONTENT_LENGTH_H_
+#define _THTTP_HEADER_CONTENT_LENGTH_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_HEADER_CONTENT_LENGTH_VA_ARGS(length) thttp_header_Content_Length_def_t, (uint32_t)length
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// HTTP header 'Content-Length'.
+///
+/// @par ABNF: Content-Length / l
+/// Content-Length = "Content-Length" HCOLON 1*DIGIT
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct thttp_header_Content_Length_s
+{
+ THTTP_DECLARE_HEADER;
+
+ uint32_t length;
+}
+thttp_header_Content_Length_t;
+
+thttp_header_Content_Length_t *thttp_header_Content_Length_parse(const char *data, tsk_size_t size);
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Content_Length_def_t;
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_CONTENT_LENGTH_H_ */
+
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_Content_Type.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_Content_Type.h
new file mode 100644
index 0000000..17e0d53
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_Content_Type.h
@@ -0,0 +1,76 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_Content_Type.h
+ * @brief HTTP header 'Content-Type'.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef _THTTP_HEADER_CONTENT_TYPE_H_
+#define _THTTP_HEADER_CONTENT_TYPE_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_HEADER_CONTENT_TYPE_VA_ARGS(type) thttp_header_Content_Type_def_t, (const char*)type
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// HTTP header 'Content-Type'.
+///
+/// @par ABNF= Content-Type
+/// Content-Type = ( "Content-Type" ) HCOLON media-type
+/// media-type = m-type SLASH m-subtype *( SEMI m-parameter)
+/// m-type = discrete-type / composite-type
+/// discrete-type = "text" / "image" / "audio" / "video" / "application" / extension-token
+/// composite-type = "message" / "multipart" / extension-token
+/// extension-token = ietf-token / x-token
+/// ietf-token = token
+/// x-token = "x-" token
+/// m-subtype = extension-token / iana-token
+/// iana-token = token
+/// m-parameter = m-attribute EQUAL m-value
+/// m-attribute = token
+/// m-value = token / quoted-string
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct thttp_header_Content_Type_s
+{
+ THTTP_DECLARE_HEADER;
+
+ char* type;
+}
+thttp_header_Content_Type_t;
+
+
+thttp_header_Content_Type_t *thttp_header_Content_Type_parse(const char *data, tsk_size_t size);
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Content_Type_def_t;
+
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_CONTENT_TYPE_H_ */
+
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_Dummy.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_Dummy.h
new file mode 100644
index 0000000..9e5293d
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_Dummy.h
@@ -0,0 +1,62 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_Dummy.h
+ * @brief HTTP dummy header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef _THTTP_HEADER_DUMMY_H_
+#define _THTTP_HEADER_DUMMY_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_HEADER_DUMMY_VA_ARGS(name, value) thttp_header_Dummy_def_t, (const char*)name, (const char*)value
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// HTTP Dummy header.
+///
+/// @par ABNF : token SP* HCOLON SP*<: any*
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct thttp_header_Dummy_s
+{
+ THTTP_DECLARE_HEADER;
+
+ char *name;
+ char *value;
+}
+thttp_header_Dummy_t;
+
+thttp_header_Dummy_t *thttp_header_Dummy_parse(const char *data, tsk_size_t size);
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Dummy_def_t;
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_DUMMY_H_ */
+
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_ETag.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_ETag.h
new file mode 100644
index 0000000..651520b
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_ETag.h
@@ -0,0 +1,67 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_ETag.h
+ * @brief HTTP 'ETag' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef _THTTP_HEADER_ETAG_H_
+#define _THTTP_HEADER_ETAG_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_HEADER_ETAG_VA_ARGS(value) thttp_header_ETag_def_t, (const char*)value
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// HTTP ETag header.
+///
+/// @par ABNF : ETag = "ETag" ":" entity-tag
+/// entity-tag = [ weak ] opaque-tag
+/// weak = "W/"
+/// opaque-tag = quoted-string
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct thttp_header_ETag_s
+{
+ THTTP_DECLARE_HEADER;
+
+ char *value;
+ tsk_bool_t isWeak;
+}
+thttp_header_ETag_t;
+
+thttp_header_ETag_t *thttp_header_ETag_parse(const char *data, tsk_size_t size);
+
+thttp_header_ETag_t* thttp_header_etag_create(const char* value);
+thttp_header_ETag_t* thttp_header_etag_create_null();
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_ETag_def_t;
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_ETAG_H_ */
+
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Accept.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Accept.h
new file mode 100644
index 0000000..b13ab4e
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Accept.h
@@ -0,0 +1,56 @@
+/*
+* Copyright (C) 2012 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango(dot)org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_Sec_WebSocket_Accept.h
+ * @brief WebSocket 'Sec-WebSocket-Accept.h' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango(dot)org>
+ *
+ */
+#ifndef _THTTP_HEADER_SEC_WEBSOCKET_ACCEPT_H_
+#define _THTTP_HEADER_SEC_WEBSOCKET_ACCEPT_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_HEADER_SEC_WEBSOCKET_ACCEPT_VA_ARGS(key) thttp_header_Sec_WebSocket_Accept_def_t, (const char*)key
+
+typedef struct thttp_header_Sec_WebSocket_Accept_s
+{
+ THTTP_DECLARE_HEADER;
+
+ char *value;
+}
+thttp_header_Sec_WebSocket_Accept_t;
+
+thttp_header_Sec_WebSocket_Accept_t *thttp_header_Sec_WebSocket_Accept_parse(const char *data, tsk_size_t size);
+
+thttp_header_Sec_WebSocket_Accept_t* thttp_header_Sec_WebSocket_Accept_create(const char* value);
+thttp_header_Sec_WebSocket_Accept_t* thttp_header_Sec_WebSocket_Accept_create_null();
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Sec_WebSocket_Accept_def_t;
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_SEC_WEBSOCKET_ACCEPT_H_ */
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Key.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Key.h
new file mode 100644
index 0000000..679551a
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Key.h
@@ -0,0 +1,56 @@
+/*
+* Copyright (C) 2012 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango(dot)org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_Sec_WebSocket_Key.h
+ * @brief WebSocket 'Sec-WebSocket-Key.h' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango(dot)org>
+ *
+ */
+#ifndef _THTTP_HEADER_SEC_WEBSOCKET_KEY_H_
+#define _THTTP_HEADER_SEC_WEBSOCKET_KEY_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_HEADER_SEC_WEBSOCKET_KEY_VA_ARGS(key) thttp_header_Sec_WebSocket_Key_def_t, (const char*)key
+
+typedef struct thttp_header_Sec_WebSocket_Key_s
+{
+ THTTP_DECLARE_HEADER;
+
+ char *value;
+}
+thttp_header_Sec_WebSocket_Key_t;
+
+thttp_header_Sec_WebSocket_Key_t *thttp_header_Sec_WebSocket_Key_parse(const char *data, tsk_size_t size);
+
+thttp_header_Sec_WebSocket_Key_t* thttp_header_Sec_WebSocket_Key_create(const char* value);
+thttp_header_Sec_WebSocket_Key_t* thttp_header_Sec_WebSocket_Key_create_null();
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Sec_WebSocket_Key_def_t;
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_SEC_WEBSOCKET_KEY_H_ */
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Protocol.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Protocol.h
new file mode 100644
index 0000000..c132c66
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Protocol.h
@@ -0,0 +1,58 @@
+/*
+* Copyright (C) 2012 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango(dot)org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_Sec_WebSocket_Protocol.h
+ * @brief WebSocket 'Sec-WebSocket-Protocol.h' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango(dot)org>
+ *
+ */
+#ifndef _THTTP_HEADER_SEC_WEBSOCKET_PROTOCOL_H_
+#define _THTTP_HEADER_SEC_WEBSOCKET_PROTOCOL_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+#include "tsk_string.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_HEADER_SEC_WEBSOCKET_PROTOCOL_VA_ARGS(protocol) thttp_header_Sec_WebSocket_Protocol_def_t, (const char*)protocol
+
+typedef struct thttp_header_Sec_WebSocket_Protocol_s
+{
+ THTTP_DECLARE_HEADER;
+
+ tsk_strings_L_t *values;
+}
+thttp_header_Sec_WebSocket_Protocol_t;
+
+thttp_header_Sec_WebSocket_Protocol_t *thttp_header_Sec_WebSocket_Protocol_parse(const char *data, tsk_size_t size);
+
+thttp_header_Sec_WebSocket_Protocol_t* thttp_header_Sec_WebSocket_Protocol_create(const char* protocol);
+thttp_header_Sec_WebSocket_Protocol_t* thttp_header_Sec_WebSocket_Protocol_create_null();
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Sec_WebSocket_Protocol_def_t;
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_SEC_WEBSOCKET_PROTOCOL_H_ */
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Version.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Version.h
new file mode 100644
index 0000000..777d787
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_Sec_WebSocket_Version.h
@@ -0,0 +1,58 @@
+/*
+* Copyright (C) 2012 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango(dot)org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_Sec_WebSocket_Version.h
+ * @brief WebSocket 'Sec-WebSocket-Version.h' header.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango(dot)org>
+ *
+ */
+#ifndef _THTTP_HEADER_SEC_WEBSOCKET_VERSION_H_
+#define _THTTP_HEADER_SEC_WEBSOCKET_VERSION_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+#include "tsk_string.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_HEADER_SEC_WEBSOCKET_VERSION_VA_ARGS(version) thttp_header_Sec_WebSocket_Version_def_t, (const char*)version
+
+typedef struct thttp_header_Sec_WebSocket_Version_s
+{
+ THTTP_DECLARE_HEADER;
+
+ tsk_strings_L_t *values;
+}
+thttp_header_Sec_WebSocket_Version_t;
+
+thttp_header_Sec_WebSocket_Version_t *thttp_header_Sec_WebSocket_Version_parse(const char *data, tsk_size_t size);
+
+thttp_header_Sec_WebSocket_Version_t* thttp_header_Sec_WebSocket_Version_create(const char* version);
+thttp_header_Sec_WebSocket_Version_t* thttp_header_Sec_WebSocket_Version_create_null();
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Sec_WebSocket_Version_def_t;
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_SEC_WEBSOCKET_VERSION_H_ */
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_Transfer_Encoding.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_Transfer_Encoding.h
new file mode 100644
index 0000000..762834e
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_Transfer_Encoding.h
@@ -0,0 +1,76 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_Transfer_Encoding.h
+ * @brief HTTP header 'Transfer-Encoding'.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef _THTTP_HEADER_TRANSFER_ENCODING_H_
+#define _THTTP_HEADER_TRANSFER_ENCODING_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_HEADER_TRANSFER_ENCODING_VA_ARGS(encoding) thttp_header_Transfer_Encoding_def_t, (const char*)encoding
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// HTTP header 'Transfer-Encoding'.
+///
+/// @par ABNF= Transfer-Encoding = "Transfer-Encoding" ":" transfer-coding *(COMMA transfer-coding)
+///
+/// transfer-coding = "chunked" / transfer-extension
+/// transfer-extension = token *( ";" parameter )
+/// parameter = attribute "=" value
+/// attribute = token
+/// value = token / quoted-string
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct thttp_header_Transfer_Encoding_s
+{
+ THTTP_DECLARE_HEADER;
+
+ char* encoding;
+}
+thttp_header_Transfer_Encoding_t;
+
+
+thttp_header_Transfer_Encoding_t *thttp_header_Transfer_Encoding_parse(const char *data, tsk_size_t size);
+
+thttp_header_Transfer_Encoding_t* thttp_header_transfer_encoding_create(const char* encoding);
+thttp_header_Transfer_Encoding_t* thttp_header_transfer_encoding_create_null();
+
+
+thttp_header_Transfer_Encoding_t* thttp_header_transfer_encoding_create(const char* encoding);
+thttp_header_Transfer_Encoding_t* thttp_header_transfer_encoding_create_null();
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_Transfer_Encoding_def_t;
+
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_TRANSFER_ENCODING_H_ */
+
diff --git a/tinyHTTP/include/tinyhttp/headers/thttp_header_WWW_Authenticate.h b/tinyHTTP/include/tinyhttp/headers/thttp_header_WWW_Authenticate.h
new file mode 100644
index 0000000..f01dc23
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/headers/thttp_header_WWW_Authenticate.h
@@ -0,0 +1,82 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_header_WWW_Authenticate.h
+ * @brief HTTP header 'WWW-Authenticate'.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef _THTTP_HEADER_WWW_Authenticate_H_
+#define _THTTP_HEADER_WWW_Authenticate_H_
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/headers/thttp_header.h"
+
+THTTP_BEGIN_DECLS
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+///
+/// HTTP header 'WWW-Authenticate'.
+///
+/// @par ABNF = WWW-Authenticate = "WWW-Authenticate" HCOLON challenge
+/// challenge = ("Digest" LWS digest-cln *(COMMA digest-cln)) / other-challenge
+/// other-challenge = auth-scheme / auth-param *(COMMA auth-param)
+/// digest-cln = realm / domain / nonce / opaque / stale / algorithm / qop-options / auth-param
+/// realm = "realm" EQUAL realm-value
+/// realm-value = quoted-string
+/// domain = "domain" EQUAL LDQUOT URI *( 1*SP URI ) RDQUOT
+/// URI = absoluteURI / abs-path
+/// opaque = "opaque" EQUAL quoted-string
+/// stale = "stale" EQUAL ( "true" / "false" )
+/// qop-options = "qop" EQUAL LDQUOT qop-value *("," qop-value) RDQUOT
+/// qop-value = "auth" / "auth-int" / token
+///
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct thttp_header_WWW_Authenticate_s
+{
+ THTTP_DECLARE_HEADER;
+
+ char* scheme;
+ char* realm;
+ char* domain;
+ char* nonce;
+ char* opaque;
+ tsk_bool_t stale;
+ char* algorithm;
+ char* qop;
+}
+thttp_header_WWW_Authenticate_t;
+
+typedef thttp_header_WWW_Authenticate_t thttp_header_Proxy_Authenticate_t;
+
+TINYHTTP_API thttp_header_WWW_Authenticate_t *thttp_header_WWW_Authenticate_parse(const char *data, tsk_size_t size);
+TINYHTTP_API thttp_header_Proxy_Authenticate_t *thttp_header_Proxy_Authenticate_parse(const char *data, tsk_size_t size);
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_header_WWW_Authenticate_def_t;
+
+THTTP_END_DECLS
+
+#endif /* _THTTP_HEADER_WWW_Authenticate_H_ */
+
diff --git a/tinyHTTP/include/tinyhttp/parsers/thttp_parser_header.h b/tinyHTTP/include/tinyhttp/parsers/thttp_parser_header.h
new file mode 100644
index 0000000..8162fb9
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/parsers/thttp_parser_header.h
@@ -0,0 +1,44 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_parser_header.h
+ * @brief HTTP headers parser.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef TINYHTTP_PARSER_HEADERS_H
+#define TINYHTTP_PARSER_HEADERS_H
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/thttp_message.h"
+#include "tsk_ragel_state.h"
+
+THTTP_BEGIN_DECLS
+
+TINYHTTP_API int thttp_header_parse(tsk_ragel_state_t *state, thttp_message_t *message);
+
+THTTP_END_DECLS
+
+#endif /* TINYHTTP_PARSER_HEADERS_H */
+
diff --git a/tinyHTTP/include/tinyhttp/parsers/thttp_parser_message.h b/tinyHTTP/include/tinyhttp/parsers/thttp_parser_message.h
new file mode 100644
index 0000000..09aad4b
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/parsers/thttp_parser_message.h
@@ -0,0 +1,44 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_parser_message.h
+ * @brief HTTP message parser.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef TINYHTTP_PARSER_MESSAGE_H
+#define TINYHTTP_PARSER_MESSAGE_H
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/thttp_message.h"
+#include "tsk_ragel_state.h"
+
+THTTP_BEGIN_DECLS
+
+TINYHTTP_API int thttp_message_parse(tsk_ragel_state_t *state, thttp_message_t **result, tsk_bool_t extract_content);
+
+THTTP_END_DECLS
+
+#endif /* TINYHTTP_PARSER_MESSAGE_H */
+
diff --git a/tinyHTTP/include/tinyhttp/parsers/thttp_parser_url.h b/tinyHTTP/include/tinyhttp/parsers/thttp_parser_url.h
new file mode 100644
index 0000000..4bfdb99
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/parsers/thttp_parser_url.h
@@ -0,0 +1,45 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_parser_url.h
+ * @brief HTTP/HTTPS URL parser.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef TINYHTTP_PARSER_URL_H
+#define TINYHTTP_PARSER_URL_H
+
+#include "tinyhttp_config.h"
+#include "tinyhttp/thttp_url.h"
+
+#include "tsk_ragel_state.h"
+
+THTTP_BEGIN_DECLS
+
+TINYHTTP_API thttp_url_t *thttp_url_parse(const char *data, tsk_size_t size);
+
+THTTP_END_DECLS
+
+#endif /* TINYHTTP_PARSER_URL_H */
+
diff --git a/tinyHTTP/include/tinyhttp/thttp_action.h b/tinyHTTP/include/tinyhttp/thttp_action.h
new file mode 100644
index 0000000..afc98d6
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/thttp_action.h
@@ -0,0 +1,251 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_action.h
+ * @brief HTTP action.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef THTTP_ACTION_H
+#define THTTP_ACTION_H
+
+#include "tinyhttp_config.h"
+
+#include "tinyhttp/thttp_session.h"
+
+#include "tsk_buffer.h"
+#include "tsk_list.h"
+#include "tsk_params.h"
+#include "tsk_options.h"
+
+THTTP_BEGIN_DECLS
+
+typedef uint64_t thttp_action_id_t;
+#define THTTP_ACTION_INVALID_ID 0
+#define THTTP_ACTION_INVALID_HANDLE tsk_null
+
+/** List of all supported options.
+* To pass an option to the sesion, use @ref THTTP_ACTION_SET_OPTION() macro.
+*/
+typedef enum thttp_action_option_e
+{
+ THTTP_ACTION_OPTION_TIMEOUT,
+
+}
+thttp_action_option_t;
+
+/** List of actions.
+*/
+typedef enum thttp_action_type_e
+{
+ /* Outgoing GET, PUT, HEAD, DELETE, .... */
+ thttp_atype_o_request,
+ /* Incoming message */
+ thttp_atype_i_message,
+
+ /* common */
+ thttp_thttp_atype_closed,
+ thttp_atype_error,
+ thttp_atype_close,
+ thttp_atype_cancel,
+ thttp_atype_timedout,
+
+}
+thttp_action_type_t;
+
+typedef enum thttp_action_param_type_e
+{
+ thttp_aptype_null = 0,
+
+ thttp_aptype_option,
+ thttp_aptype_header,
+ thttp_aptype_payload,
+}
+thttp_action_param_type_t;
+
+/**@ingroup thttp_action_group
+* @def THTTP_ACTION_SET_OPTION
+* Adds or updates an option.
+* This is a helper macro for @a thttp_action_*() functions.
+* @param ID_ENUM The id of the option to add/update (@ref thttp_action_option_t).
+* @param VALUE_STR The new value of the parameter (<i>const char*</i>).
+*
+* @code
+thttp_action_GET(session, "http://www.google.com",
+ THTTP_ACTION_SET_PARAM("timeout", "6000"),
+ THTTP_ACTION_SET_NULL());
+* @endcode
+*/
+/**@ingroup thttp_action_group
+* @def THTTP_ACTION_SET_HEADER
+* Adds new HTTP headers to the request.
+* This is a helper macro for @a thttp_action_*() functions.
+* @param NAME_STR The name of the header (<i>const char*</i>).
+* @param VALUE_STR The value of the header (<i>const char*</i>). Should not contains the trailing CRLF.
+*
+* @code
+thttp_action_GET(session, "http://www.doubango.org"
+ THTTP_ACTION_SET_HEADER("Pragma", "No-Cache"),
+ THTTP_ACTION_SET_HEADER("Connection", "Keep-Alive"),
+ THTTP_ACTION_SET_NULL());
+* @endcode
+*/
+/**@ingroup thttp_action_group
+* @def THTTP_ACTION_SET_PAYLOAD
+* Adds a content (or payload) to the request. You should also add a content-type header by using
+* @ref THTTP_ACTION_SET_HEADER() macro. You should not add the content-length header.
+* This is a helper macro for @a thttp_action_*() functions.
+* @param PAY_PTR A pointer to the payload (<i>const void*</i>).
+* @param PAY_SIZE The size of the payload (<i>tsk_size_t</i>).
+*
+* @code
+thttp_action_PUT(session, "http://www.doubango.org"
+ THTTP_ACTION_SET_HEADER("Pragma", "No-Cache"),
+ THTTP_ACTION_SET_HEADER("Connection", "Keep-Alive"),
+ THTTP_ACTION_SET_HEADER("Content-length", "application/mytype"),
+
+ THTTP_ACTION_SET_PAYLOAD("Salut", 5),
+
+ THTTP_ACTION_SET_NULL());
+* @endcode
+*/
+/**@ingroup thttp_action_group
+* @def THTTP_ACTION_SET_NULL
+* Ends action parameters. Must always be the last one.
+*/
+#define THTTP_ACTION_SET_OPTION(ID_ENUM, VALUE_STR) thttp_aptype_option, (thttp_action_option_t)ID_ENUM, (const char*)VALUE_STR
+#define THTTP_ACTION_SET_HEADER(NAME_STR, VALUE_STR) thttp_aptype_header, (const char*)NAME_STR, (const char*)VALUE_STR
+#define THTTP_ACTION_SET_PAYLOAD(PAY_PTR, PAY_SIZE) thttp_aptype_payload, (const void*)PAY_PTR, (tsk_size_t)PAY_SIZE
+#define THTTP_ACTION_SET_NULL() thttp_aptype_null
+
+typedef struct thttp_action_s
+{
+ TSK_DECLARE_OBJECT;
+
+ thttp_action_type_t type;
+ const char* url;
+ const char* method;
+
+ tsk_options_L_t *options;
+ tsk_params_L_t *headers;
+ tsk_buffer_t* payload;
+}
+thttp_action_t;
+
+typedef void thttp_action_handle_t;
+
+/**@ingroup thttp_action_group
+* @def thttp_action_CONNECT
+* Sends @a CONNECT method request. This function is non-blocking and the result will be posted to the callback function.
+* @param session The @a session (or connection) to use.
+* @param urlstring The Request-URI of the request.
+* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
+* @retval Zero if succeed and non-zero error code otherwise.
+*/
+/**@ingroup thttp_action_group
+* @def thttp_action_DELETE
+* Sends @a DELETE method request. This function is non-blocking and the result will be posted to the callback function.
+* @param session The @a session (or connection) to use.
+* @param urlstring The Request-URI of the request.
+* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
+* @retval Zero if succeed and non-zero error code otherwise.
+*/
+/**@ingroup thttp_action_group
+* @def thttp_action_GET
+* Sends @a GET method request. This function is non-blocking and the result will be posted to the callback function.
+* @param session The @a session (or connection) to use.
+* @param urlstring The Request-URI of the request.
+* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
+* @retval Zero if succeed and non-zero error code otherwise.
+*/
+/**@ingroup thttp_action_group
+* @def thttp_action_HEAD
+* Sends @a HEAD method request. This function is non-blocking and the result will be posted to the callback function.
+
+* @param session The @a session (or connection) to use.
+* @param urlstring The Request-URI of the request.
+* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
+* @retval Zero if succeed and non-zero error code otherwise.
+*/
+/**@ingroup thttp_action_group
+* @def thttp_action_OPTIONS
+* Sends @a OPTIONS method request. This function is non-blocking and the result will be posted to the callback function.
+* @param session The @a session (or connection) to use.
+* @param urlstring The Request-URI of the request.
+* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
+* @retval Zero if succeed and non-zero error code otherwise.
+*/
+/**@ingroup thttp_action_group
+* @def thttp_action_PATCH
+* Sends @a PATCH method request. This function is non-blocking and the result will be posted to the callback function.
+
+* @param session The @a session (or connection) to use.
+* @param urlstring The Request-URI of the request.
+* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
+* @retval Zero if succeed and non-zero error code otherwise.
+*/
+/**@ingroup thttp_action_group
+* @def thttp_action_POST
+* Sends @a POST method request. This function is non-blocking and the result will be posted to the callback function.
+* @param session The @a session (or connection) to use.
+* @param urlstring The Request-URI of the request.
+* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
+* @retval Zero if succeed and non-zero error code otherwise.
+*/
+/**@ingroup thttp_action_group
+* @def thttp_action_PUT
+* Sends @a PUT method request. This function is non-blocking and the result will be posted to the callback function.
+* @param session The @a session (or connection) to use.
+* @param urlstring The Request-URI of the request.
+* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
+* @retval Zero if succeed and non-zero error code otherwise.
+*/
+/**@ingroup thttp_action_group
+* @def thttp_action_TRACE
+* Sends @a TRACE method request. This function is non-blocking and the result will be posted to the callback function.
+* @param session The @a session (or connection) to use.
+* @param urlstring The Request-URI of the request.
+* @param ... Any @b THTTP_ACTION_SET_*() macros. MUST ends with @ref THTTP_ACTION_SET_NULL().
+* @retval Zero if succeed and non-zero error code otherwise.
+*/
+TINYHTTP_API int thttp_action_perform(thttp_session_handle_t *session, const char* urlstring, const char* method, ...);
+#define thttp_action_CONNECT(session, urlstring, ...) thttp_action_perform(session, urlstring, "CONNECT", __VA_ARGS__)
+#define thttp_action_DELETE(session, urlstring, ...) thttp_action_perform(session, urlstring, "DELETE", __VA_ARGS__)
+#define thttp_action_GET(session, urlstring, ...) thttp_action_perform(session, urlstring, "GET", __VA_ARGS__)
+#define thttp_action_HEAD(session, urlstring, ...) thttp_action_perform(session, urlstring, "HEAD", __VA_ARGS__)
+#define thttp_action_OPTIONS(session, urlstring, ...) thttp_action_perform(session, urlstring, "OPTIONS", __VA_ARGS__)
+#define thttp_action_PATCH(session, urlstring, ...) thttp_action_perform(session, urlstring, "PATCH", __VA_ARGS__)
+#define thttp_action_POST(session, urlstring, ...) thttp_action_perform(session, urlstring, "POST", __VA_ARGS__)
+#define thttp_action_PUT(session, urlstring, ...) thttp_action_perform(session, urlstring, "PUT", __VA_ARGS__)
+#define thttp_action_TRACE(session, urlstring, ...) thttp_action_perform(session, urlstring, "TRACE", __VA_ARGS__)
+
+TINYHTTP_API thttp_action_t* thttp_action_create(thttp_action_type_t type, const char* urlstring, const char* method, va_list* app);
+
+typedef tsk_list_t thttp_actions_L_t; /**< List of @ref thttp_action_handle_t elements. */
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_action_def_t;
+
+THTTP_END_DECLS
+
+#endif /* THTTP_ACTION_H */
+
diff --git a/tinyHTTP/include/tinyhttp/thttp_dialog.h b/tinyHTTP/include/tinyhttp/thttp_dialog.h
new file mode 100644
index 0000000..f9885ab
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/thttp_dialog.h
@@ -0,0 +1,73 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_dialog.h
+ * @brief HTTP Dialog.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef THTTP_DIALOG_H
+#define THTTP_DIALOG_H
+
+#include "tinyhttp_config.h"
+
+#include "tsk_fsm.h"
+#include "tsk_list.h"
+#include "tsk_buffer.h"
+
+THTTP_BEGIN_DECLS
+
+struct thttp_message_s;
+
+typedef uint64_t thttp_dialog_id_t;
+
+typedef struct thttp_dialog_s
+{
+ TSK_DECLARE_OBJECT;
+
+ thttp_dialog_id_t id;
+ uint64_t timestamp;
+
+ tsk_fsm_t* fsm;
+
+ tsk_buffer_t* buf;
+
+ struct thttp_session_s* session;
+ struct thttp_action_s* action;
+ tsk_bool_t answered;
+}
+thttp_dialog_t;
+
+typedef tsk_list_t thttp_dialogs_L_t;
+
+TINYHTTP_API int thttp_dialog_fsm_act(thttp_dialog_t* self, tsk_fsm_action_id , const struct thttp_message_s* , const struct thttp_action_s*);
+TINYHTTP_API thttp_dialog_t* thttp_dialog_new(struct thttp_session_s* session);
+thttp_dialog_t* thttp_dialog_get_oldest(thttp_dialogs_L_t* dialogs);
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_dialog_def_t;
+
+THTTP_END_DECLS
+
+#endif /* THTTP_DIALOG_H */
+
diff --git a/tinyHTTP/include/tinyhttp/thttp_event.h b/tinyHTTP/include/tinyhttp/thttp_event.h
new file mode 100644
index 0000000..9c57b97
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/thttp_event.h
@@ -0,0 +1,75 @@
+/*
+* Copyright (C) 2010-2011 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_event.h
+ * @brief HTTP/HTTPS event.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
+ *
+
+ */
+#ifndef TINYHTTP_EVENT_H
+#define TINYHTTP_EVENT_H
+
+#include "tinyhttp_config.h"
+
+#include "tinyhttp/thttp_session.h"
+
+#include "tsk_object.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_EVENT(self) ((thttp_event_t*)(self))
+
+typedef enum thttp_event_type_e
+{
+ thttp_event_dialog_started,
+ thttp_event_message,
+ thttp_event_auth_failed,
+ thttp_event_closed,
+ thttp_event_transport_error,
+ thttp_event_dialog_terminated
+}
+thttp_event_type_t;
+
+typedef struct thttp_event_s
+{
+ TSK_DECLARE_OBJECT;
+
+ thttp_event_type_t type;
+ const thttp_session_handle_t* session;
+
+ char* description;
+
+ struct thttp_message_s *message;
+}
+thttp_event_t;
+
+typedef int (*thttp_stack_callback_f)(const thttp_event_t *httpevent);
+
+thttp_event_t* thttp_event_create(thttp_event_type_t type, const thttp_session_handle_t* session, const char* description, const thttp_message_t* message);
+
+TINYHTTP_GEXTERN const void *thttp_event_def_t;
+
+THTTP_END_DECLS
+
+#endif /* TINYHTTP_EVENT_H */
diff --git a/tinyHTTP/include/tinyhttp/thttp_message.h b/tinyHTTP/include/tinyhttp/thttp_message.h
new file mode 100644
index 0000000..4f9d1e5
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/thttp_message.h
@@ -0,0 +1,263 @@
+/*
+* Copyright (C) 2010-2015 Mamadou DIOP.
+*
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_message.h
+ * @brief Represents a HTTP message. A HTTP message is either a request from a client to a server, or a
+ * response from a server to a client.
+ *
+ */
+#ifndef THTTP_MESSAGE_H
+#define THTTP_MESSAGE_H
+
+#include "tinyhttp_config.h"
+
+#include "tinyhttp/thttp_url.h"
+
+//#include "tinyhttp/headers/thttp_header_Call_ID.h"
+//#include "tinyhttp/headers/thttp_header_Contact.h"
+#include "tinyhttp/headers/thttp_header_Content_Length.h"
+#include "tinyhttp/headers/thttp_header_Content_Type.h"
+//#include "tinyhttp/headers/thttp_header_CSeq.h"
+//#include "tinyhttp/headers/thttp_header_Expires.h"
+//#include "tinyhttp/headers/thttp_header_From.h"
+//#include "tinyhttp/headers/thttp_header_P_Access_Network_Info.h"
+//#include "tinyhttp/headers/thttp_header_Via.h"
+
+#include "tsk_object.h"
+#include "tsk_buffer.h"
+
+/**@ingroup thttp_message_group
+* @def THTTP_MESSAGE_VERSION_10
+* HTTP version 1.0.
+*/
+/**@ingroup thttp_message_group
+* @def THTTP_MESSAGE_VERSION_11
+* HTTP version 1.1.
+*/
+/**@ingroup thttp_message_group
+* @def THTTP_MESSAGE_VERSION_20
+* HTTP version 2.0.
+*/
+/**@ingroup thttp_message_group
+* @def THTTP_MESSAGE_VERSION_DEFAULT
+* Default HTTP version. Default value is @ref THTTP_MESSAGE_VERSION_11.
+*/
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_MESSAGE_VERSION_10 "HTTP/1.0"
+#define THTTP_MESSAGE_VERSION_11 "HTTP/1.1"
+#define THTTP_MESSAGE_VERSION_20 "HTTP/2.0"
+#define THTTP_MESSAGE_VERSION_DEFAULT THTTP_MESSAGE_VERSION_11
+
+/**@ingroup thttp_message_group
+* @def THTTP_MESSAGE_IS_REQUEST
+* Checks whether the HTTP message is a request or not.
+* @param self A pointer to a valid @ref thttp_message_t object.
+* @retval @ref tsk_true if @a self is a request and @a tsk_false otherwise.
+*/
+/**@ingroup thttp_message_group
+* @def THTTP_MESSAGE_IS_RESPONSE
+* Checks whether the HTTP message is a response or not.
+* @param self A pointer to a valid @ref thttp_message_t object.
+* @retval @ref tsk_true if @a self is a response and @a tsk_false otherwise.
+*/
+#define THTTP_MESSAGE_IS_REQUEST(self) ((self) ? (self)->type == thttp_request : tsk_false)
+#define THTTP_MESSAGE_IS_RESPONSE(self) ((self) ? (self)->type == thttp_response : tsk_false)
+
+/**@ingroup thttp_message_group
+* @def THTTP_MESSAGE
+* Casts any pointer to a pointer to @ref thttp_message_t.
+* @retval A pointer to @ref thttp_message_t.
+*/
+/**@ingroup thttp_message_group
+* @def THTTP_MESSAGE_AS_RESPONSE
+* Casts any pointer to a pointer to @ref thttp_response_t.
+* @retval A pointer to @ref thttp_response_t.
+*/
+/**@ingroup thttp_message_group
+* @def THTTP_MESSAGE_AS_REQUEST
+* Casts any pointer to a pointer to @ref thttp_request_t.
+* @retval A pointer to @ref thttp_request_t.
+*/
+#define THTTP_MESSAGE(self) ((thttp_message_t*)(self))
+#define THTTP_MESSAGE_AS_RESPONSE(self) ((thttp_response_t*)(self))
+#define THTTP_MESSAGE_AS_REQUEST(self) ((thttp_request_t*)(self))
+
+
+/**@ingroup thttp_message_group
+*@def THTTP_RESPONSE_CODE
+* Gets the status code of the response.
+* @param self A pointer to a @ref thttp_response_t object.
+* @retval The status code (short).
+*/
+/**@ingroup thttp_message_group
+*@def THTTP_RESPONSE_PHRASE
+* Gets the reason phrase of the response.
+* @param self A pointer to a @ref thttp_response_t object.
+* @retval The phrase (const char*).
+*/
+
+#define THTTP_RESPONSE_CODE(self) (THTTP_MESSAGE_IS_RESPONSE((self)) ? (self)->line.response.status_code : 0)
+#define THTTP_RESPONSE_PHRASE(self) ((self)->line.response.reason_phrase)
+
+/**@ingroup thttp_message_group
+*@def THTTP_REQUEST_METHOD
+* Gets the method of the request.
+* @param self A pointer to a @ref thttp_request_t object.
+* @retval The method (const char*).
+*/
+/**@ingroup thttp_message_group
+*@def THTTP_REQUEST_URL
+* Gets the URL of the request.
+* @param self A pointer to a @ref thttp_request_t object.
+* @retval The Url (@ref thttp_url_t).
+*/
+#define THTTP_REQUEST_METHOD(self) ((self) ? (self)->line.request.method : tsk_null)
+#define THTTP_REQUEST_URL(self) ((self) ? (self)->line.request.url : tsk_null)
+
+/**@ingroup thttp_message_group
+*@def THTTP_MESSAGE_CONTENT_LENGTH
+* Gets the content length.
+* @param self A pointer to a @ref thttp_message_t object.
+* @retval The content length (uint32_t).
+*/
+/**@ingroup thttp_message_group
+*@def THTTP_MESSAGE_CONTENT
+* Gets the content value.
+* @param self A pointer to a @ref thttp_message_t object.
+* @retval A pointer to the content (void*).
+*/
+/**@ingroup thttp_message_group
+*@def THTTP_MESSAGE_HAS_CONTENT
+* Checks whether the message has a content or not.
+* @param self A pointer to a @ref thttp_message_t object.
+* @retval @ref tsk_true if the message has a content and @a tsk_false otherwise.
+*/
+#define THTTP_MESSAGE_CONTENT_LENGTH(self) (uint32_t)(((self) && (self)->Content_Length) ? (self)->Content_Length->length : 0)
+#define THTTP_MESSAGE_CONTENT(self) (THTTP_MESSAGE_HAS_CONTENT(self) ? (self)->Content->data : 0)
+#define THTTP_MESSAGE_HAS_CONTENT(self) ((self) && (self)->Content)
+
+#define THTTP_RESPONSE_IS(self, code) (THTTP_RESPONSE_CODE((self)) == code)
+#define THTTP_RESPONSE_IS_NXX(self, N) (N##00<= THTTP_RESPONSE_CODE((self)) && THTTP_RESPONSE_CODE((self)) <= N##99)
+#define THTTP_RESPONSE_IS_1XX(self) THTTP_RESPONSE_IS_NXX(self, 1)
+#define THTTP_RESPONSE_IS_2XX(self) THTTP_RESPONSE_IS_NXX(self, 2)
+#define THTTP_RESPONSE_IS_3XX(self) THTTP_RESPONSE_IS_NXX(self, 3)
+#define THTTP_RESPONSE_IS_4XX(self) THTTP_RESPONSE_IS_NXX(self, 4)
+#define THTTP_RESPONSE_IS_5XX(self) THTTP_RESPONSE_IS_NXX(self, 5)
+#define THTTP_RESPONSE_IS_6XX(self) THTTP_RESPONSE_IS_NXX(self, 6)
+#define THTTP_RESPONSE_IS_23456(self) (200<= THTTP_RESPONSE_CODE((self)) && THTTP_RESPONSE_CODE((self)) <= 699)
+
+/**Defines the message type (Request or Response).
+**/
+typedef enum thttp_message_type_e
+{
+ thttp_unknown,
+ thttp_request,
+ thttp_response
+}
+thttp_message_type_t;
+
+/**Represents a HTTP message. A HTTP message is either a request from a client to a server,
+ * or a response from a server to a client.
+**/
+typedef struct thttp_message_s
+{
+ TSK_DECLARE_OBJECT;
+
+ char *http_version; /**< The HTTP version. Only 'HTTP/1.1' is supported. */
+ thttp_message_type_t type; /**< The type of this HTTP message. */
+
+ /* Request-Line */
+ union{
+ struct{
+ char *method;
+ thttp_url_t *url;
+ } request;
+ struct{
+ short status_code;
+ char *reason_phrase;
+ } response;
+ } line;
+
+ /*== MOST COMMON HEADERS. */
+ thttp_header_Content_Type_t *Content_Type;
+ thttp_header_Content_Length_t *Content_Length;
+ tsk_buffer_t *Content;
+
+ /*== OTHER HEADERS*/
+ thttp_headers_L_t *headers;
+}
+thttp_message_t;
+
+typedef thttp_message_t thttp_request_t; /**< HTTP request message. */
+typedef thttp_message_t thttp_response_t; /**< HTTP response message. */
+
+//
+TINYHTTP_API int thttp_message_add_header(thttp_message_t *self, const thttp_header_t *hdr);
+TINYHTTP_API int thttp_message_add_headers(thttp_message_t *self, const thttp_headers_L_t *headers);
+TINYHTTP_API int thttp_message_add_headers_2(thttp_message_t *self, ...);
+TINYHTTP_API int thttp_message_add_content(thttp_message_t *self, const char* content_type, const void* content, tsk_size_t size);
+TINYHTTP_API int thttp_message_append_content(thttp_message_t *self, const void* content, tsk_size_t size);
+
+#if defined(__SYMBIAN32__) && 0
+static void THTTP_MESSAGE_ADD_HEADER(thttp_message_t *self, ...)
+ {
+ va_list ap;
+ thttp_header_t *header;
+ const tsk_object_def_t *objdef;
+
+ va_start(ap, self);
+ objdef = va_arg(ap, const tsk_object_def_t*);
+ header = tsk_object_new_2(objdef, &ap);
+ va_end(ap);
+
+ thttp_message_add_header(self, header);
+ tsk_object_unref(header);
+ }
+#else
+#define THTTP_MESSAGE_ADD_HEADER(self, objdef, ...) \
+ { \
+ thttp_header_t *header = (thttp_header_t *)tsk_object_new(objdef, ##__VA_ARGS__); \
+ thttp_message_add_header(self, header); \
+ tsk_object_unref(header); \
+ }
+#endif
+
+TINYHTTP_API const thttp_header_t *thttp_message_get_headerAt(const thttp_message_t *self, thttp_header_type_t type, tsk_size_t index);
+TINYHTTP_API const thttp_header_t *thttp_message_get_header(const thttp_message_t *self, thttp_header_type_t type);
+TINYHTTP_API const thttp_header_t *thttp_message_get_headerByName(const thttp_message_t *self, const char* name);
+
+TINYHTTP_API int thttp_message_serialize(const thttp_message_t *self, tsk_buffer_t *output);
+TINYHTTP_API char* thttp_message_tostring(const thttp_message_t *self);
+
+TINYHTTP_API thttp_request_t *thttp_request_new(const char* method, const thttp_url_t *request_url);
+TINYHTTP_API thttp_response_t *thttp_response_new(short status_code, const char* reason_phrase, const thttp_request_t *request);
+
+TINYHTTP_API thttp_message_t* thttp_message_create();
+TINYHTTP_API thttp_request_t* thttp_request_create(const char* method, const thttp_url_t* url);
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_message_def_t;
+
+THTTP_END_DECLS
+
+#endif /* THTTP_MESSAGE_H */
+
diff --git a/tinyHTTP/include/tinyhttp/thttp_proxy_node_plugin.h b/tinyHTTP/include/tinyhttp/thttp_proxy_node_plugin.h
new file mode 100644
index 0000000..ed4138b
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/thttp_proxy_node_plugin.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010-2015 Mamadou DIOP.
+ * Copyright (C) 2015 Doubango Telecom.
+ *
+ * This file is part of Open Source Doubango Framework.
+ *
+ * DOUBANGO is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DOUBANGO is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DOUBANGO.
+ *
+ */
+#if !defined(TINYHTTP_PROXY_NODE_PLUGIN_H)
+#define TINYHTTP_PROXY_NODE_PLUGIN_H
+
+#include "tinyhttp_config.h"
+
+THTTP_BEGIN_DECLS
+
+TINYHTTP_GEXTERN const struct tnet_proxy_node_plugin_def_s* thttp_proxy_node_plugin_def_t;
+
+THTTP_END_DECLS
+
+
+#endif /* TINYHTTP_PROXY_NODE_PLUGIN_H */
diff --git a/tinyHTTP/include/tinyhttp/thttp_session.h b/tinyHTTP/include/tinyhttp/thttp_session.h
new file mode 100644
index 0000000..3d740e5
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/thttp_session.h
@@ -0,0 +1,207 @@
+/*
+* Copyright (C) 2010-2015 Mamadou DIOP.
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_session.h
+ * @brief HTTP session.
+ *
+ */
+#ifndef THTTP_SESSION_H
+#define THTTP_SESSION_H
+
+#include "tinyhttp_config.h"
+
+#include "tinyhttp/auth/thttp_challenge.h"
+#include "tinyhttp/thttp_message.h"
+
+#include "tinyhttp/thttp_dialog.h"
+
+#include "tnet_types.h"
+
+#include "tsk_object.h"
+#include "tsk_list.h"
+#include "tsk_params.h"
+#include "tsk_options.h"
+
+THTTP_BEGIN_DECLS
+
+//FD
+struct thttp_message_s;
+
+typedef uint64_t thttp_session_id_t;
+#define THTTP_SESSION_INVALID_ID 0
+#define THTTP_SESSION_INVALID_HANDLE tsk_null
+
+/** List of all supported options.
+* To pass an option to the sesion, use @ref THTTP_SESSION_SET_OPTION() macro.
+*/
+typedef enum thttp_session_option_e
+{
+ THTTP_SESSION_OPTION_TIMEOUT,
+ THTTP_SESSION_OPTION_TTL,
+ // To be continued...
+}
+thttp_session_option_t;
+
+typedef enum thttp_session_param_type_e
+{
+ httpp_null = 0,
+
+ httpp_option,
+ httpp_cred,
+ httpp_header,
+ httpp_userdata,
+}
+thttp_session_param_type_t;
+
+/**@ingroup thttp_session_group
+* @def THTTP_SESSION_SET_OPTION
+* Adds or updates an option.
+* This is a helper macro for @ref thttp_session_create and @ref thttp_session_set.
+* @param ID_ENUM The id of the option to add/update (@ref thttp_session_option_t).
+* @param VALUE_STR The new value of the option (<i>const char*</i>).
+*
+* @code
+// session = thttp_session_create(stack,
+thttp_session_set(session,
+ THTTP_SESSION_SET_PARAM(THTTP_SESSION_OPTION_TIMEOUT, "6000"),
+ THTTP_SESSION_SET_NULL());
+* @endcode
+*/
+/**@ingroup thttp_session_group
+* @def THTTP_SESSION_SET_CRED
+* Sets the user's creadentials.
+* This is a helper macro for @ref thttp_session_create and @ref thttp_session_set.
+* @param USERNAME_STR The username (const char*).
+* @param PASSWORD_STR The password(const char*).
+*
+* @code
+// session = thttp_session_create(stack,
+thttp_session_set(session,
+ THTTP_SESSION_SET_CRED("ali baba", "open sesame"),
+ THTTP_SESSION_SET_NULL());
+* @endcode
+*/
+/**@ingroup thttp_session_group
+* @def THTTP_SESSION_SET_HEADER
+* Adds new HTTP headers to the session. The value of the header will be updated if it already exist.
+* This is a helper macro for @ref thttp_session_create and @ref thttp_session_set.
+* @param NAME_STR The name of the header (<i>const char*</i>) to add or update.
+* @param VALUE_STR The value of the header (<i>const char*</i>). Should not contains the trailing CRLF.
+* @sa @ref THTTP_SESSION_UNSET_HEADER
+*
+* @code
+// session = thttp_session_create(stack,
+thttp_session_set(session,
+ THTTP_SESSION_SET_HEADER("Pragma", "No-Cache"),
+ THTTP_SESSION_SET_HEADER("Connection", "Keep-Alive"),
+ THTTP_SESSION_SET_NULL());
+* @endcode
+*/
+/**@ingroup thttp_session_group
+* @def THTTP_SESSION_UNSET_HEADER
+* Removes a header. This header should be previously added by using @ref THTTP_SESSION_SET_HEADER().
+* This is a helper macro for @ref thttp_session_create and @ref thttp_session_set.
+* @param NAME_STR The name of the header (<i>const char*</i>) to remove.
+* @sa @ref THTTP_SESSION_SET_HEADER
+*
+* @code
+// session = thttp_session_create(stack,
+thttp_session_set(session,
+ THTTP_SESSION_UNSET_HEADER("Pragma"),
+ THTTP_SESSION_UNSET_HEADER("Connection"),
+ THTTP_SESSION_SET_NULL());
+* @endcode
+*/
+/**@ingroup thttp_session_group
+* @def THTTP_SESSION_SET_USERDATA
+* Sets user data (context). Will be return to the application layer each time the callback function is called.
+* This is a helper macro for @ref thttp_session_create and @ref thttp_session_set.
+* @param USERDATA_PTR A pointer to the data(const void*).
+*
+* @code
+// session = thttp_session_create(stack,
+thttp_session_set(session,
+ THTTP_SESSION_SET_USERDATA(ctx),
+ THTTP_SESSION_SET_NULL());
+* @endcode
+*/
+/**@ingroup thttp_session_group
+* @def THTTP_SESSION_SET_NULL
+* Ends session parameters. Must always be the last one.
+*/
+#define THTTP_SESSION_SET_OPTION(ID_ENUM, VALUE_STR) httpp_option, (thttp_session_option_t)ID_ENUM, (const char*)VALUE_STR
+#define THTTP_SESSION_SET_CRED(USERNAME_STR, PASSWORD_STR) httpp_cred, (const char*)USERNAME_STR, (const char*)PASSWORD_STR
+#define THTTP_SESSION_SET_HEADER(NAME_STR, VALUE_STR) httpp_header, (const char*)NAME_STR, (const char*)VALUE_STR
+#define THTTP_SESSION_UNSET_HEADER(NAME_STR) THTTP_SESSION_SET_HEADER(NAME_STR, (const char*)-1)
+#define THTTP_SESSION_SET_USERDATA(USERDATA_PTR) httpp_userdata, (const void*)USERDATA_PTR
+#define THTTP_SESSION_SET_NULL() httpp_null
+
+typedef struct thttp_session_s
+{
+ TSK_DECLARE_OBJECT;
+
+ thttp_session_id_t id;
+ const struct thttp_stack_s* stack;
+ const void* userdata; // user's context
+ tsk_options_L_t *options;
+ tsk_params_L_t *headers;
+
+ tnet_fd_t fd;
+
+ thttp_challenges_L_t *challenges;
+ thttp_dialogs_L_t* dialogs;
+
+ struct{
+ char* usename;
+ char* password;
+ }cred;
+
+ TSK_DECLARE_SAFEOBJ;
+}
+thttp_session_t;
+
+typedef tsk_list_t thttp_sessions_L_t; /**< List of @ref thttp_session_handle_t elements. */
+
+/** Pointer to a HTTP/HTTPS session. */
+typedef void thttp_session_handle_t;
+/** Pointer to a HTTP/HTTPS stack object. */
+typedef void thttp_stack_handle_t;
+
+TINYHTTP_API thttp_session_handle_t* thttp_session_create(const thttp_stack_handle_t* stack, ...);
+TINYHTTP_API int thttp_session_set(thttp_session_handle_t *self, ...);
+TINYHTTP_API thttp_session_id_t thttp_session_get_id(const thttp_session_handle_t *self);
+TINYHTTP_API const void* thttp_session_get_userdata(const thttp_session_handle_t *self);
+TINYHTTP_API int thttp_session_closefd(thttp_session_handle_t *self);
+
+int thttp_session_update_challenges(thttp_session_t *self, const thttp_response_t* response, tsk_bool_t answered);
+
+int thttp_session_signal_closed(thttp_session_t *self);
+int thttp_session_signal_error(thttp_session_t *self);
+
+
+thttp_session_t* thttp_session_get_by_fd(thttp_sessions_L_t* sessions, tnet_fd_t fd);
+
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_session_def_t;
+
+THTTP_END_DECLS
+
+#endif /* THTTP_SESSION_H */
+
diff --git a/tinyHTTP/include/tinyhttp/thttp_url.h b/tinyHTTP/include/tinyhttp/thttp_url.h
new file mode 100644
index 0000000..802f84d
--- /dev/null
+++ b/tinyHTTP/include/tinyhttp/thttp_url.h
@@ -0,0 +1,93 @@
+/*
+* Copyright (C) 2010-2015 Mamadou DIOP.
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+
+/**@file thttp_url.h
+ * @brief HTTP/HTTPS URL.
+ *
+ */
+#ifndef TINYHTTP_URL_H
+#define TINYHTTP_URL_H
+
+#include "tinyhttp_config.h"
+
+#include "tsk_object.h"
+#include "tsk_params.h"
+#include "tsk_buffer.h"
+
+THTTP_BEGIN_DECLS
+
+#define THTTP_URL_IS_SECURE(url) ((url && url->type==thttp_url_https) ? 1 : 0)
+
+/** Url type.
+*/
+typedef enum thttp_url_type_e
+{
+ thttp_url_unknown,
+ thttp_url_http,
+ thttp_url_https,
+}
+thttp_url_type_t;
+
+typedef enum thttp_host_type_e
+{
+ thttp_host_unknown,
+ thttp_host_hostname,
+ thttp_host_ipv4,
+ thttp_host_ipv6
+}
+thttp_host_type_t;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/// @struct thttp_url_t
+///
+/// @brief HTTP/HTTPS URL.
+///
+/// ABNF (Compact: From RFC 1738): httpurl = "http://" hostport [ "/" hpath [ "?" search ]]
+/// hpath = hsegment *[ "/" hsegment ]
+/// hsegment = *[ uchar | ";" | ":" | "@" | "&" | "=" ]
+/// search = *[ uchar | ";" | ":" | "@" | "&" | "=" ]
+////////////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct thttp_url_s
+{
+ TSK_DECLARE_OBJECT;
+
+ thttp_url_type_t type;
+ char *scheme;
+ char *host; /**< Host name. Hostname or IPv4address or IPv6address. */
+ char *hpath;
+ char *search;
+ thttp_host_type_t host_type; /**< IPv4 or IPv6 or domain name. */
+ uint16_t port;
+}
+thttp_url_t;
+
+TINYHTTP_API int thttp_url_serialize(const thttp_url_t *url, tsk_buffer_t *output);
+TINYHTTP_API char* thttp_url_tostring(const thttp_url_t *url);
+TINYHTTP_API thttp_url_t *thttp_url_clone(const thttp_url_t *url);
+TINYHTTP_API tsk_bool_t thttp_url_isvalid(const char* urlstring);
+
+thttp_url_t* thttp_url_create(thttp_url_type_t type);
+
+TINYHTTP_GEXTERN const tsk_object_def_t *thttp_url_def_t;
+
+THTTP_END_DECLS
+
+#endif /* TINYHTTP_URL_H */
+
OpenPOWER on IntegriCloud