comparison packages/net/athttpd/current/include/http.h @ 2326:bd648d8929f6

* cdl/httpd.cdl: Improve CDL dependencies. * doc/athttpd.sgml: Updated to describe lasted changes and corrected minor typos. * src/http.c: Check for "Content-Type" header. This is needed if we want to support parsing form variables in POST requests. * src/jim.c: Updated with latest release from Jim CVS. * src/cgi.c: streamlined cyg_httpd_exec_cgi_tcl(), now uses the 'source' command of tcl to execute a tcl script. * src/forms.c: Modified cyg_handle_method_POST so that the variables in the payload are scanned only if the request has a Content-Type of 'application/x-www-form-urlencoded' * src/jim-aio.c: Added to package. Now tcl has IO functions to access a file system. * include/httpd.h: Added a new mode, CYG_HTTPD_MODE_FORM_DATA which is set when a POST request has a Content-Type of 'application/x-www-form-urlencoded' * cdl/httpd.cdl: add CYGOPT_NET_ATHTTPD_CLOSE_CHUNKED_CONNECTIONS. Default is set to CLOSE, so it is backward compatible with previous versions of the browser. * src/socket.c: cyg_httpd_process_request() uses a loop to collect at least one full frame (til a header terminator is found), cyg_httpd_start_chunked() only close if configured to do so. * src/httpd.c: Overhaul of cyg_httpd_send_error to avoid the use of inbuffer as temporary storage (conflicts with pipelined frames), removed the option to send a page after calling a C language handler * include/httpd.h: Added a new mode, CYG_HTTPD_MODE_NO_CACHE 2006-10-12 Lars Povlsen <lpovlsen@vitesse.com> and Anthony Tonizzo <atonizzo@gmail.com> * cdl/httpd.cdl: add CYGNUM_ATHTTPD_SERVER_MAX_POST to limit POST'ed data * include/http.h: Added header_end, post_data fields to httpstate, Added "302 Found" for POST handler redirect (CYG_HTTPD_STATUS_MOVED_TEMPORARILY) * src/forms.c: Fixed variable decoding, fixed large POST processing * src/http.c: Fixed some debug ouptuts, cleanup after POST processing, overhaul of the pipelined requests code which can now handle multiple requests per frame. * src/socket.c: Removed assert for socket write failure, Accumulating receiving of requests (Browsers (Firefox) may pass partial headers in separate fragments). Fixed some diagnostics output.
author jlarmour
date Mon, 27 Nov 2006 15:41:55 +0000
parents 0830ae6acddc
children 0e9d1d1df4a0
comparison
equal deleted inserted replaced
2325:29ca0a2d4a0f 2326:bd648d8929f6
67 #endif 67 #endif
68 68
69 69
70 typedef enum cyg_httpd_req_type 70 typedef enum cyg_httpd_req_type
71 { 71 {
72 CYG_HTTPD_METHOD_GET = 1, 72 CYG_HTTPD_METHOD_GET = 1,
73 CYG_HTTPD_METHOD_HEAD = 2, 73 CYG_HTTPD_METHOD_HEAD = 2,
74 CYG_HTTPD_METHOD_POST = 3 74 CYG_HTTPD_METHOD_POST = 3
75 } cyg_httpd_req_type; 75 } cyg_httpd_req_type;
76 76
77 #define CYG_HTTPD_MAXURL 128 77 #define CYG_HTTPD_MAXURL 128
85 85
86 #define CYG_HTTPD_TIME_STRING_LEN 32 86 #define CYG_HTTPD_TIME_STRING_LEN 32
87 87
88 #define CYG_HTTPD_STATUS_OK 200 88 #define CYG_HTTPD_STATUS_OK 200
89 #define CYG_HTTPD_STATUS_MOVED_PERMANENTLY 301 89 #define CYG_HTTPD_STATUS_MOVED_PERMANENTLY 301
90 #define CYG_HTTPD_STATUS_MOVED_TEMPORARILY 302
90 #define CYG_HTTPD_STATUS_NOT_MODIFIED 304 91 #define CYG_HTTPD_STATUS_NOT_MODIFIED 304
91 #define CYG_HTTPD_STATUS_BAD_REQUEST 400 92 #define CYG_HTTPD_STATUS_BAD_REQUEST 400
92 #define CYG_HTTPD_STATUS_NOT_AUTHORIZED 401 93 #define CYG_HTTPD_STATUS_NOT_AUTHORIZED 401
93 #define CYG_HTTPD_STATUS_FORBIDDEN 403 94 #define CYG_HTTPD_STATUS_FORBIDDEN 403
94 #define CYG_HTTPD_STATUS_NOT_FOUND 404 95 #define CYG_HTTPD_STATUS_NOT_FOUND 404
96 #define CYG_HTTPD_STATUS_SYSTEM_ERROR 500 97 #define CYG_HTTPD_STATUS_SYSTEM_ERROR 500
97 #define CYG_HTTPD_STATUS_NOT_IMPLEMENTED 501 98 #define CYG_HTTPD_STATUS_NOT_IMPLEMENTED 501
98 99
99 #define CYG_HTTPD_MODE_CLOSE_CONN 0x0001 100 #define CYG_HTTPD_MODE_CLOSE_CONN 0x0001
100 #define CYG_HTTPD_MODE_TRANSFER_CHUNKED 0x0002 101 #define CYG_HTTPD_MODE_TRANSFER_CHUNKED 0x0002
101 #define CYG_HTTPD_SEND_HEADER_ONLY 0x0004 102 #define CYG_HTTPD_MODE_SEND_HEADER_ONLY 0x0004
103 #define CYG_HTTPD_MODE_NO_CACHE 0x0008
104 #define CYG_HTTPD_MODE_FORM_DATA 0x0010
102 105
103 // This must be generated at random... 106 // This must be generated at random...
104 #define CYG_HTTPD_MD5_AUTH_NAME "MD5" 107 #define CYG_HTTPD_MD5_AUTH_NAME "MD5"
105 #define CYG_HTTPD_MD5_AUTH_QOP "auth" 108 #define CYG_HTTPD_MD5_AUTH_QOP "auth"
106 #define CYG_HTTPD_MD5_AUTH_OPAQUE "0000000000000000" 109 #define CYG_HTTPD_MD5_AUTH_OPAQUE "0000000000000000"
107 110
111 #define TIME_FORMAT_RFC1123 "%a, %d %b %Y %H:%H:%S GMT"
112
108 typedef struct __socket_entry 113 typedef struct __socket_entry
109 { 114 {
110 cyg_int32 descriptor; 115 cyg_int32 descriptor;
111 time_t timestamp; 116 time_t timestamp;
112 } socket_entry; 117 } socket_entry;
120 fd_set rfds; 125 fd_set rfds;
121 126
122 cyg_int32 host[4]; 127 cyg_int32 host[4];
123 128
124 char url[CYG_HTTPD_MAXURL+1]; 129 char url[CYG_HTTPD_MAXURL+1];
125 char inbuffer[CYG_HTTPD_MAXINBUFFER+1]; 130 char inbuffer[CYG_HTTPD_MAXINBUFFER+1];
126 cyg_int32 inbuffer_len; 131 cyg_int32 inbuffer_len, content_len;
127 132
128
129 // Packet status. 133 // Packet status.
130 // 134 //
131 // bit Description 135 // bit Description
132 // ------------------------------------------------------------------------- 136 // -------------------------------------------------------------------------
133 // 0 When set inserts 'Pragma: no-cache' and 137 // 0 A 1 means that the connection will be closed after the request
134 // 'Cache-control: no-cache' in the header. Default for callback 138 // has been served (i.e. Connection: close" will appear in
135 // functions. 139 // the header. Otherwise the connection will be kept alive
136 // 1 When to close the connection: 140 // "Connection: keep-alive"
137 // 'Connection: close' when 0, 'Connection: keep-alive' when 1. 141 // 1 Set when the transfer will be chunked
142 // 2 Set when the we need to send only the header
143 // 3 Set when the we do not want this document to be cached (i.e.
144 // "Cache-Control: no-cache" will appear in the header) which
145 // is meant for c language callbacks and GCI.
146 // 4 Set when the the frame we just received contains form data.
147 // In this case we call the function that parsed the data into
148 // user-defined form variables.
138 cyg_uint16 mode; 149 cyg_uint16 mode;
139 150
140 // Ouptut data. 151 // Ouptut data.
141 cyg_uint16 status_code; 152 cyg_uint16 status_code;
142 char *mime_type; 153 char *mime_type;
143 cyg_int32 payload_len; 154 cyg_int32 payload_len;
144 char outbuffer[CYG_HTTPD_MAXOUTBUFFER+1]; 155 char outbuffer[CYG_HTTPD_MAXOUTBUFFER+1];
145 156
146 socket_entry sockets[CYGNUM_FILEIO_NFILE]; 157 socket_entry sockets[CYGNUM_FILEIO_NFILE];
147 cyg_int32 fdmax; 158 cyg_int32 fdmax;
148 159
149 // Socket handle. 160 // Socket handle.
150 cyg_int32 client_index; 161 cyg_int32 client_index;
153 time_t last_modified; 164 time_t last_modified;
154 165
155 #ifdef CYGOPT_NET_ATHTTPD_USE_CGIBIN_TCL 166 #ifdef CYGOPT_NET_ATHTTPD_USE_CGIBIN_TCL
156 Jim_Interp *jim_interp; 167 Jim_Interp *jim_interp;
157 #endif 168 #endif
169
170 // Pointer to the data immediately following the last byte of the header.
171 // In a POST request, this is where the goods are.
172 char *header_end;
173
174 // This pointer points to the buffer where we collected all the post
175 // data (it might come in more than one frame) and must be visible to
176 // handlers and cgi scripts.
177 char *post_data;
158 178
159 // This pointer points to the information about the domain that needs 179 // This pointer points to the information about the domain that needs
160 // to be authenticated. It is only used by the function that builds the 180 // to be authenticated. It is only used by the function that builds the
161 // header. 181 // header.
162 cyg_httpd_auth_table_entry *needs_auth; 182 cyg_httpd_auth_table_entry *needs_auth;
182 cyg_httpd_mime_table_entry __name CYG_HAL_TABLE_ENTRY(httpd_mime_table) = \ 202 cyg_httpd_mime_table_entry __name CYG_HAL_TABLE_ENTRY(httpd_mime_table) = \
183 { __pattern, __arg } 203 { __pattern, __arg }
184 204
185 extern cyg_int32 debug_print; 205 extern cyg_int32 debug_print;
186 206
187 void cyg_httpd_format_time_string(char*, time_t*);
188 void cyg_httpd_set_home_page(cyg_int8*); 207 void cyg_httpd_set_home_page(cyg_int8*);
189 char* cyg_httpd_find_mime_string(char*); 208 char* cyg_httpd_find_mime_string(char*);
190 cyg_int32 cyg_httpd_initialize(void); 209 cyg_int32 cyg_httpd_initialize(void);
191 void cyg_httpd_cleanup_filename(char*); 210 void cyg_httpd_cleanup_filename(char*);
192 char* cyg_httpd_parse_GET(char*); 211 char* cyg_httpd_parse_GET(char*);
193 char* cyg_httpd_parse_POST(char*); 212 char* cyg_httpd_parse_POST(char*);
194 char* cyg_httpd_parse_HEAD(char*);
195 void cyg_httpd_handle_method_GET(void); 213 void cyg_httpd_handle_method_GET(void);
196 void cyg_httpd_handle_method_HEAD(void); 214 void cyg_httpd_handle_method_HEAD(void);
197 cyg_int32 cyg_httpd_process_method(void); 215 void cyg_httpd_process_method(void);
198 void cyg_httpd_send_file(char*); 216 void cyg_httpd_send_file(char*);
199 void cyg_httpd_send_error(cyg_int32); 217 void cyg_httpd_send_error(cyg_int32);
200 cyg_int32 cyg_httpd_format_header(void); 218 cyg_int32 cyg_httpd_format_header(void);
201 219
202 #endif 220 #endif