Mercurial > ecos
annotate packages/net/athttpd/current/include/http.h @ 2729:74dbf4c3f2e1 after-copyright-change-20090129
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
| author | jlarmour |
|---|---|
| date | Thu, 29 Jan 2009 17:47:46 +0000 |
| parents | 0e9d1d1df4a0 |
| children |
| rev | line source |
|---|---|
| 2250 | 1 /* ================================================================= |
| 2 * | |
| 3 * http.h | |
| 4 * | |
| 5 * Improved HTTPD server. | |
| 6 * | |
| 7 * ================================================================= | |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
8 * ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
9 * ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
10 * This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
11 * Copyright (C) 2005 Free Software Foundation, Inc. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
12 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
13 * eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
14 * the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
15 * Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
16 * version. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
17 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
18 * eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
21 * for more details. |
| 2250 | 22 * |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
23 * You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
24 * along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
26 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
27 * As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
28 * macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
29 * and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
30 * this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
31 * the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
32 * must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
33 * General Public License v2. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
34 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
35 * This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
36 * on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
37 * ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
38 * ####ECOSGPLCOPYRIGHTEND#### |
| 2250 | 39 * ================================================================= |
| 40 * #####DESCRIPTIONBEGIN#### | |
| 41 * | |
| 42 * Author(s): Anthony Tonizzo (atonizzo@gmail.com) | |
| 43 * Contributors: | |
| 44 * Date: 2006-06-12 | |
| 45 * Purpose: | |
| 46 * Description: | |
| 47 * | |
| 48 * ####DESCRIPTIONEND#### | |
| 49 * | |
| 50 * ================================================================= | |
| 51 */ | |
| 52 #ifndef __HTTP_H__ | |
| 53 #define __HTTP_H__ | |
| 54 | |
| 55 #include <pkgconf/system.h> | |
| 56 #include <pkgconf/isoinfra.h> | |
| 57 #include <cyg/hal/hal_tables.h> | |
| 58 | |
| 59 #include <pkgconf/athttpd.h> | |
| 60 #include <cyg/athttpd/auth.h> | |
| 61 | |
| 62 #ifdef CYGOPT_NET_ATHTTPD_USE_CGIBIN_TCL | |
| 63 #include <cyg/athttpd/jim.h> | |
| 64 #endif | |
| 65 | |
| 66 | |
| 67 typedef enum cyg_httpd_req_type | |
| 68 { | |
| 2326 | 69 CYG_HTTPD_METHOD_GET = 1, |
| 2250 | 70 CYG_HTTPD_METHOD_HEAD = 2, |
| 71 CYG_HTTPD_METHOD_POST = 3 | |
| 72 } cyg_httpd_req_type; | |
| 73 | |
| 74 #define CYG_HTTPD_MAXURL 128 | |
| 75 #define CYG_HTTPD_MAXPATH 128 | |
| 76 | |
| 77 #define CYG_HTTPD_MAXINBUFFER CYGNUM_ATHTTPD_SERVER_BUFFER_SIZE | |
| 78 #define CYG_HTTPD_MAXOUTBUFFER CYGNUM_ATHTTPD_SERVER_BUFFER_SIZE | |
| 79 | |
| 80 #define CYG_HTTPD_DEFAULT_CGIBIN_OBJLOADER_EXTENSION ".o" | |
| 81 #define CYG_HTTPD_DEFAULT_CGIBIN_TCL_EXTENSION ".tcl" | |
| 82 | |
| 83 #define CYG_HTTPD_TIME_STRING_LEN 32 | |
| 84 | |
| 85 #define CYG_HTTPD_STATUS_OK 200 | |
| 86 #define CYG_HTTPD_STATUS_MOVED_PERMANENTLY 301 | |
| 2326 | 87 #define CYG_HTTPD_STATUS_MOVED_TEMPORARILY 302 |
| 2250 | 88 #define CYG_HTTPD_STATUS_NOT_MODIFIED 304 |
| 89 #define CYG_HTTPD_STATUS_BAD_REQUEST 400 | |
| 90 #define CYG_HTTPD_STATUS_NOT_AUTHORIZED 401 | |
| 91 #define CYG_HTTPD_STATUS_FORBIDDEN 403 | |
| 92 #define CYG_HTTPD_STATUS_NOT_FOUND 404 | |
| 93 #define CYG_HTTPD_STATUS_METHOD_NOT_ALLOWED 405 | |
| 94 #define CYG_HTTPD_STATUS_SYSTEM_ERROR 500 | |
| 95 #define CYG_HTTPD_STATUS_NOT_IMPLEMENTED 501 | |
| 96 | |
| 97 #define CYG_HTTPD_MODE_CLOSE_CONN 0x0001 | |
| 98 #define CYG_HTTPD_MODE_TRANSFER_CHUNKED 0x0002 | |
| 2326 | 99 #define CYG_HTTPD_MODE_SEND_HEADER_ONLY 0x0004 |
| 100 #define CYG_HTTPD_MODE_NO_CACHE 0x0008 | |
| 101 #define CYG_HTTPD_MODE_FORM_DATA 0x0010 | |
| 2250 | 102 |
| 103 // This must be generated at random... | |
| 104 #define CYG_HTTPD_MD5_AUTH_NAME "MD5" | |
| 105 #define CYG_HTTPD_MD5_AUTH_QOP "auth" | |
| 106 #define CYG_HTTPD_MD5_AUTH_OPAQUE "0000000000000000" | |
| 107 | |
| 2326 | 108 #define TIME_FORMAT_RFC1123 "%a, %d %b %Y %H:%H:%S GMT" |
| 109 | |
| 2250 | 110 typedef struct __socket_entry |
| 111 { | |
| 112 cyg_int32 descriptor; | |
| 113 time_t timestamp; | |
| 114 } socket_entry; | |
| 115 | |
| 116 // ============================================================================= | |
| 117 // Main HTTP structure. | |
| 118 // ============================================================================= | |
| 119 typedef struct | |
| 120 { | |
| 121 cyg_httpd_req_type method; | |
| 122 fd_set rfds; | |
| 123 | |
| 124 cyg_int32 host[4]; | |
| 125 | |
| 126 char url[CYG_HTTPD_MAXURL+1]; | |
| 2326 | 127 char inbuffer[CYG_HTTPD_MAXINBUFFER+1]; |
| 128 cyg_int32 inbuffer_len, content_len; | |
| 129 | |
| 2250 | 130 // Packet status. |
| 131 // | |
| 132 // bit Description | |
| 133 // ------------------------------------------------------------------------- | |
| 2326 | 134 // 0 A 1 means that the connection will be closed after the request |
| 135 // has been served (i.e. Connection: close" will appear in | |
| 136 // the header. Otherwise the connection will be kept alive | |
| 137 // "Connection: keep-alive" | |
| 138 // 1 Set when the transfer will be chunked | |
| 139 // 2 Set when the we need to send only the header | |
| 140 // 3 Set when the we do not want this document to be cached (i.e. | |
| 141 // "Cache-Control: no-cache" will appear in the header) which | |
| 142 // is meant for c language callbacks and GCI. | |
| 143 // 4 Set when the the frame we just received contains form data. | |
| 144 // In this case we call the function that parsed the data into | |
| 145 // user-defined form variables. | |
| 2250 | 146 cyg_uint16 mode; |
| 147 | |
| 148 // Ouptut data. | |
| 149 cyg_uint16 status_code; | |
| 150 char *mime_type; | |
| 151 cyg_int32 payload_len; | |
| 152 char outbuffer[CYG_HTTPD_MAXOUTBUFFER+1]; | |
| 2326 | 153 |
|
2485
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
154 socket_entry sockets[CYGPKG_NET_MAXSOCKETS]; |
| 2250 | 155 cyg_int32 fdmax; |
| 156 | |
| 157 // Socket handle. | |
| 158 cyg_int32 client_index; | |
| 159 | |
|
2485
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
160 // Modified-since is always reset to -1 before parsing the headers of a |
|
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
161 // request. If the "Modified-Since" element is present in the header then |
|
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
162 // we'll copy the value in this variable, otherwise it will remain to -1. |
|
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
163 // This will tell us if we can send a CYG_HTTPD_STATUS_NOT_MODIFIED back to |
|
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
164 // the client or instead we'll have to send the whole page again. |
| 2250 | 165 time_t modified_since; |
| 166 time_t last_modified; | |
| 167 | |
| 168 #ifdef CYGOPT_NET_ATHTTPD_USE_CGIBIN_TCL | |
| 169 Jim_Interp *jim_interp; | |
| 170 #endif | |
| 171 | |
| 2326 | 172 // Pointer to the data immediately following the last byte of the header. |
|
2485
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
173 // In a POST request, this is where the goods are. After the post request |
|
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
174 // is handles it will point to the start of the new request, if any. |
|
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
175 char *request_end; |
| 2326 | 176 |
| 177 // This pointer points to the buffer where we collected all the post | |
| 178 // data (it might come in more than one frame) and must be visible to | |
| 179 // handlers and cgi scripts. | |
| 180 char *post_data; | |
| 181 | |
| 2250 | 182 // This pointer points to the information about the domain that needs |
| 183 // to be authenticated. It is only used by the function that builds the | |
| 184 // header. | |
| 185 cyg_httpd_auth_table_entry *needs_auth; | |
| 186 | |
| 187 struct sockaddr_in server_conn; | |
| 188 struct sockaddr_in client_conn; | |
| 189 } CYG_HTTPD_STATE; | |
| 190 | |
| 191 extern CYG_HTTPD_STATE httpstate; | |
| 192 | |
| 193 extern const char *day_of_week[]; | |
| 194 extern const char *month_of_year[]; | |
| 195 | |
| 196 struct cyg_httpd_mime_table_entry | |
| 197 { | |
| 198 char *extension; | |
| 199 char *mime_string; | |
| 200 } CYG_HAL_TABLE_TYPE; | |
| 201 | |
| 202 typedef struct cyg_httpd_mime_table_entry cyg_httpd_mime_table_entry; | |
| 203 | |
| 204 #define CYG_HTTPD_MIME_TABLE_ENTRY(__name, __pattern, __arg) \ | |
| 205 cyg_httpd_mime_table_entry __name CYG_HAL_TABLE_ENTRY(httpd_mime_table) = \ | |
| 206 { __pattern, __arg } | |
| 207 | |
| 208 extern cyg_int32 debug_print; | |
| 209 | |
| 210 void cyg_httpd_set_home_page(cyg_int8*); | |
| 211 char* cyg_httpd_find_mime_string(char*); | |
| 212 cyg_int32 cyg_httpd_initialize(void); | |
| 213 void cyg_httpd_cleanup_filename(char*); | |
| 214 char* cyg_httpd_parse_GET(char*); | |
| 215 char* cyg_httpd_parse_POST(char*); | |
| 216 void cyg_httpd_handle_method_GET(void); | |
| 217 void cyg_httpd_handle_method_HEAD(void); | |
| 2326 | 218 void cyg_httpd_process_method(void); |
| 2250 | 219 void cyg_httpd_send_file(char*); |
| 220 void cyg_httpd_send_error(cyg_int32); | |
| 221 cyg_int32 cyg_httpd_format_header(void); | |
| 222 | |
| 223 #endif |
