From d2c445f5d7cf21606c9878bff3e4046c283944df Mon Sep 17 00:00:00 2001 From: snowdrop Date: Sun, 19 Sep 2004 07:05:01 +0000 Subject: Added http stream feature (only input stream yet) Added DIME "client" support (very experimental) --- nanohttp/nanohttp-common.h | 70 ++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 31 deletions(-) (limited to 'nanohttp/nanohttp-common.h') diff --git a/nanohttp/nanohttp-common.h b/nanohttp/nanohttp-common.h index 455e9ed..0d765d8 100644 --- a/nanohttp/nanohttp-common.h +++ b/nanohttp/nanohttp-common.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-common.h,v 1.10 2004/09/14 15:31:24 snowdrop Exp $ + * $Id: nanohttp-common.h,v 1.11 2004/09/19 07:05:03 snowdrop Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -27,17 +27,24 @@ #define HEADER_CONTENT_LENGTH "Content-Length" #define HEADER_CONTENT_TYPE "Content-Type" +#define HEADER_CONTENT_ID "Content-Id" +#define HEADER_CONTENT_TRANSFER_ENCODING "Content-Transfer-Encoding" #define HEADER_TRANSFER_ENCODING "Transfer-Encoding" #define HEADER_CONNECTION "Connection" #define HEADER_HOST "Host" #define HEADER_DATE "Date" - +#define HEADER_ACCEPT "Accept" #ifndef SAVE_STR #define SAVE_STR(str) ((str==0)?("(null)"):(str)) #endif +#define TRANSFER_ENCODING_CHUNKED "chunked" + +#define MAX_HEADER_SIZE 4256 +#define MAX_SOCKET_BUFFER_SIZE 4256 + /* Set Sleep function platform depended */ @@ -47,6 +54,8 @@ Set Sleep function platform depended #define system_sleep(seconds) sleep(seconds); #endif +typedef unsigned char byte_t; + /* string function to compare strings ignoring case Returns 1 if s1 equals s2 and 0 otherwise. @@ -54,6 +63,7 @@ Set Sleep function platform depended int strcmpigcase(const char *s1, const char *s2); + /* hpairnode_t represents a pair (key, value) pair. This is also a linked list. @@ -76,6 +86,11 @@ hpair_t* hpairnode_copy_deep(const hpair_t *src); void hpairnode_dump_deep(hpair_t *pair); void hpairnode_dump(hpair_t *pair); +typedef enum http_version { + HTTP_1_0, + HTTP_1_1 /* default */ +}http_version_t; + typedef enum hreq_method { HTTP_REQUEST_POST, @@ -95,40 +110,33 @@ typedef struct hurl hurl_t* hurl_new(const char* urlstr); void hurl_free(hurl_t *url); -/* - request object - */ -typedef struct hrequest -{ - char *method; - char *path; - char *spec; - hpair_t *query; - hpair_t *header; -}hrequest_t; -hrequest_t *hrequest_new_from_buffer(char *data); -void hrequest_free(hrequest_t *req); -/* response object */ +/* + DIME common stuff +*/ +#define DIME_VERSION_1 0x08 +#define DIME_FIRST_PACKAGE 0x04 +#define DIME_LAST_PACKAGE 0x02 +#define DIME_CHUNKED 0x01 +#define DIME_TYPE_URI 0x2 -typedef struct hresponse +typedef struct _DIME_PACKAGE { - char spec[10]; - int errcode; - char *desc; - hpair_t *header; - char *body; - long bodysize; -}hresponse_t; + char version; /* Specifies the version of the DIME message */ + char first_record; /* Specifies that this record is the first record of the message */ + char last_recored; /* Specifies that this record is the last record of the message */ + char chunked; /* Specifies that the contents of the message have been chunked */ + char type_t; /* Specifies the structure and format of the TYPE field */ + char *options; /* Contains any optional information used by a DIME parser */ + char *id; /* Contains a URI for uniquely identifying a DIME payload with any + additional padding; */ + char *type; /* Specifies the encoding for the record based on a type reference URI or a MIME media-type */ + int data_size; /* Specifies the length (in bytes) of the DATA */ + unsigned char* data; /* Contains the actual data payload for the record; + format of the data depends on the type specified for the record */ +}DIME_PACKAGE; -/* - PARAMS - buffer: The hole received data from socket. - */ -hresponse_t *hresponse_new_from_buffer(const char* buffer); -hresponse_t *hresponse_new(); -void hresponse_free(hresponse_t *res); /* logging stuff*/ typedef enum log_level -- cgit v1.1-32-gdbae