annotate packages/net/httpd/current/doc/httpd.sgml @ 2967:a98ace8abb52

* bsd_tcpip/current/doc/freebsd.sgml, tcpip/current/doc/openbsd.sgml: No longer "recent". * httpd/current/doc/httpd.sgml: Fix GoAhead URL.
author jld
date Sat, 18 Sep 2010 16:10:32 +0000
parents 74dbf4c3f2e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
1
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
2 <!-- =============================================================== -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
3 <!-- -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
4 <!-- httpd.sgml -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
5 <!-- -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
6 <!-- eCos HTTP Server -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
7 <!-- -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
8 <!-- =============================================================== -->
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1535
diff changeset
9 <!-- ####ECOSDOCCOPYRIGHTBEGIN#### -->
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
10 <!-- =============================================================== -->
2967
a98ace8abb52 * bsd_tcpip/current/doc/freebsd.sgml, tcpip/current/doc/openbsd.sgml:
jld
parents: 2729
diff changeset
11 <!-- Copyright (C) 2002, 2010 Free Software Foundation, Inc. -->
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
12 <!-- This material may be distributed only subject to the terms -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
13 <!-- and conditions set forth in the Open Publication License, v1.0 -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
14 <!-- or later (the latest version is presently available at -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
15 <!-- http://www.opencontent.org/openpub/) -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
16 <!-- Distribution of the work or derivative of the work in any -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
17 <!-- standard (paper) book form is prohibited unless prior -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
18 <!-- permission obtained from the copyright holder -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
19 <!-- =============================================================== -->
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1535
diff changeset
20 <!-- ####ECOSDOCCOPYRIGHTEND#### -->
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
21 <!-- =============================================================== -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
22 <!-- #####DESCRIPTIONBEGIN#### -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
23 <!-- -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
24 <!-- ####DESCRIPTIONEND#### -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
25 <!-- =============================================================== -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
26
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
27 <part id="net-httpd">
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
28 <title>Embedded HTTP Server</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
29 <chapter id="net-httpd-chapter">
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
30 <title>Embedded HTTP Server</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
31
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
32 <sect1 id="net-httpd-intro">
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
33 <title>Intrduction</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
34 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
35 The <emphasis>eCos</emphasis> HTTPD package provides a simple HTTP
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
36 server for use with applications in eCos. This server is specifically
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
37 aimed at the remote control and monitoring requirements of embedded
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
38 applications. For this reason the emphasis is on dynamically generated
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
39 content, simple forms handling and a basic CGI interface. It is
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
40 <emphasis>not</emphasis> intended to be a general purpose server for
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
41 delivering arbitrary web content. For these purposes a port of the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
42 GoAhead web server is available from <ulink
2967
a98ace8abb52 * bsd_tcpip/current/doc/freebsd.sgml, tcpip/current/doc/openbsd.sgml:
jld
parents: 2729
diff changeset
43 url="http://www.goahead.com">www.goahead.com</ulink>.
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
44 </para>
1008
4ca8a5f30c03 * src/monitor.c (cyg_monitor_network): Added IPv6 information to
asl
parents: 468
diff changeset
45 <para>This server is also capable of serving content using IPv6 when
4ca8a5f30c03 * src/monitor.c (cyg_monitor_network): Added IPv6 information to
asl
parents: 468
diff changeset
46 the eCos configuration contains IPv6.
4ca8a5f30c03 * src/monitor.c (cyg_monitor_network): Added IPv6 information to
asl
parents: 468
diff changeset
47 </para>
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
48 </sect1>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
49
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
50 <sect1 id="net-httpd-organization">
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
51 <title>Server Organization</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
52 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
53 The server consists of one or more threads running in parallel to any
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
54 application threads and which serve web pages to clients. Apart from
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
55 defining content, the application does not need to do anything to
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
56 start the HTTP server.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
57 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
58 <para>
1535
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
59 The HTTP server is, by default, started by a static constructor. This
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
60 simply creates an initial thread and sets it running. Since this is
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
61 called before the scheduler is started, nothing will happen until the
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
62 application calls <function>cyg_scheduler_start()</function>. The
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
63 server thread can also be started explicitly by the application, see
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
64 the <literal>CYGNUM_HTTPD_SERVER_AUTO_START</literal> option for
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
65 details.
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
66 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
67 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
68 When the thread gets to run it first optionally delays for some period
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
69 of time. This is to allow the application to perform any
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
70 initialization free of any interference from the HTTP server. When the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
71 thread does finally run it creates a socket, binds it to the HTTP
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
72 server port, and puts it into listen mode. It will then create any
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
73 additional HTTPD server threads that have been configured before
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
74 becoming a server thread itself.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
75 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
76 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
77 Each HTTPD server thread simply waits for a connection to be made to
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
78 the server port. When the connection is made it reads the HTTP request
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
79 and extracts the filename being accessed. If the request also contains
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
80 form data, this is also preserved. The filename is then looked up in a
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
81 table.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
82 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
83 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
84 Each table entry contains a filename pattern string, a
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
85 pointer to a handler function, and a user defined argument for the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
86 function. Table entries are defined using the same link-time table
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
87 building mechanism used to generate device tables. This is all handled
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
88 by the <literal>CYG_HTTPD_TABLE_ENTRY()</literal> macro which has the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
89 following format:
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
90 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
91 <programlisting width=72>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
92
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
93 #include &lt;cyg/httpd/httpd.h&gt;
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
94
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
95 CYG_HTTPD_TABLE_ENTRY( __name, __pattern, __handler, __arg )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
96
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
97 </programlisting>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
98 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
99 The <parameter>__name</parameter> argument is a variable name for the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
100 table entry since C does not allow us to define anonymous data
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
101 structures. This name should be chosen so that it is unique and does
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
102 not pollute the name space. The <parameter>__pattern</parameter>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
103 argument is the match pattern. The <parameter>__handler</parameter>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
104 argument is a pointer to the handler function and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
105 <parameter>__arg</parameter> the user defined value.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
106 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
107 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
108 The link-time table building means that several different pieces of
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
109 code can define server table entries, and so long as the patterns do
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
110 not clash they can be totally oblivious of each other. However, note
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
111 also that this mechanism does not guarantee the order in which entries
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
112 appear, this depends on the order of object files in the link, which
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
113 could vary from one build to the next. So any tricky pattern matching
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
114 that relies on this may not always work.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
115 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
116 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
117 A request filename matches an entry in the table if either it exactly
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
118 matches the pattern string, or if the pattern ends in an asterisk, and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
119 it matches everything up to that point. So for example the pattern
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
120 &quot;/monitor/threads.html&quot; will only match that exact filename,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
121 but the pattern &quot;/monitor/thread-*&quot; will match
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
122 &quot;/monitor/thread-0040.html&quot;,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
123 &quot;/monitor/thread-0100.html&quot; and any other filename starting
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
124 with &quot;/monitor/thread-&quot;.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
125 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
126 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
127 When a pattern is matched, the hander function is called. It has the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
128 following prototype:
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
129 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
130 <programlisting width=72>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
131 cyg_bool cyg_httpd_handler(FILE *client,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
132 char *filename,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
133 char *formdata,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
134 void *arg);
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
135 </programlisting>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
136 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
137 The <parameter>client</parameter> argument is the TCP connection to
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
138 the client: anything output through this stream will be returned to
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
139 the browser. The <parameter>filename</parameter> argument is the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
140 filename from the HTTP request and the <parameter>formdata</parameter>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
141 argument is any form response data, or NULL if none was sent. The
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
142 <parameter>arg</parameter> argument is the user defined value from the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
143 table entry.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
144 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
145 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
146 The handler is entirely responsible for generating the response to the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
147 client, both HTTP header and content. If the handler decides that it
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
148 does not want to generate a response it can return
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
149 <literal>false</literal>, in which case the table scan is resumed for
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
150 another match. If no match is found, or no handler returns true, then
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
151 a default response page is generated indicating that the requested
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
152 page cannot be found.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
153 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
154 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
155 Finally, the server thread closes the connection to the client and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
156 loops back to accept a new connection.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
157 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
158 </sect1>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
159
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
160 <!-- =============================================================== -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
161
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
162 <sect1 id="net-httpd-configuration">
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
163 <title>Server Configuration</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
164 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
165 The HTTP server has a number of configuration options:
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
166 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
167
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
168 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
169 <title><literal>CYGNUM_HTTPD_SERVER_PORT</literal></title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
170 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
171 This option defines the TCP port that the server will listen on. It
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
172 defaults to the standard HTTP port number 80. It may be changed to a
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
173 different number if, for example, another HTTP server is using the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
174 main HTTP port.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
175 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
176 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
177
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
178 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
179 <title><literal>CYGDAT_HTTPD_SERVER_ID</literal></title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
180 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
181 This is the string that is reported to the client in the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
182 &quot;Server:&quot; field of the HTTP header.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
183 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
184 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
185
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
186 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
187 <title><literal>CYGNUM_HTTPD_THREAD_COUNT</literal></title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
188 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
189 The HTTP server can be configured to use more than one thread to
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
190 service HTTP requests. If you expect to serve complex pages with many
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
191 images or other components that are fetched separately, or if any
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
192 pages may take a long time to send, then it may be useful to increase
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
193 the number of server threads. For most uses, however, the connection
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
194 queuing in the TCP/IP stack and the speed with which each page is
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
195 generated, means that a single thread is usually adequate.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
196 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
197 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
198
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
199 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
200 <title><literal>CYGNUM_HTTPD_THREAD_PRIORITY</literal></title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
201 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
202 The HTTP server threads can be run at any priority. The exact priority
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
203 depends on the importance of the server relative to the rest of the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
204 system. The default is to put them in the middle of the priority range
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
205 to provide reasonable response without impacting genuine high priority
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
206 threads.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
207 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
208 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
209
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
210 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
211 <title><literal>CYGNUM_HTTPD_THREAD_STACK_SIZE</literal></title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
212 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
213 This is the amount of stack to be allocated for each of the HTTPD
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
214 threads. The actual stack size allocated will be this value plus the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
215 values of <literal>CYGNUM_HAL_STACK_SIZE_MINIMUM</literal> and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
216 <literal>CYGNUM_HTTPD_SERVER_BUFFER_SIZE</literal>.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
217 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
218 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
219
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
220 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
221 <title><literal>CYGNUM_HTTPD_SERVER_BUFFER_SIZE</literal></title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
222 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
223 This defines the size of the buffer used to receive the first line of
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
224 each HTTP request. If you expect to use particularly long URLs or have
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
225 very complex forms, this should be increased.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
226 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
227 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
228
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
229 <sect2>
1535
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
230 <title><literal>CYGNUM_HTTPD_SERVER_AUTO_START</literal></title>
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
231 <para>
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
232 This option causes the HTTP Daemon to be started automatically during
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
233 system initialization. If this option is not set then the application
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
234 must start the daemon explicitly by calling
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
235 <function>cyg_httpd_startup()</function>. This option is set by
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
236 default.
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
237 </para>
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
238 </sect2>
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
239
00ed8504e595 Forgot to update the documentation in last checkin. Now done.
nickg
parents: 1240
diff changeset
240 <sect2>
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
241 <title><literal>CYGNUM_HTTPD_SERVER_DELAY</literal></title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
242 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
243 This defines the number of system clock ticks that the HTTP server
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
244 will wait before initializing itself and spawning any extra server
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
245 threads. This is to give the application a chance to initialize
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
246 properly without any interference from the HTTPD.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
247 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
248 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
249
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
250 </sect1>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
251
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
252 <!-- =============================================================== -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
253
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
254 <sect1 id="net-httpd-html">
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
255 <title>Support Functions and Macros</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
256 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
257 The emphasis of this server is on dynamically generated content,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
258 rather than fetching it from a filesystem. To do this the handler
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
259 functions make calls to <function>fprintf()</function> and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
260 <function>fputs()</function>. Such handler functions would end up a
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
261 mass of print calls, with the actual structure of the HTML page hidden
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
262 in the format strings and arguments, making maintenance and debugging
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
263 very difficult. Such an approach would also result in the definition
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
264 of many, often only slightly different, format strings, leading to
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
265 unnecessary bloat.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
266 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
267 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
268 In an effort to expose the structure of the HTML in the structure of
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
269 the C code, and to maximize the sharing of string constants, the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
270 <filename>cyg/httpd/httpd.h</filename> header file defines a set of
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
271 helper functions and macros. Most of these are wrappers for predefined
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
272 print calls on the <parameter>client</parameter> stream passed to the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
273 hander function. For examples of their use, see the System Monitor
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
274 example.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
275 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
276 <note>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
277 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
278 All arguments to macros are pointers to strings, unless otherwise
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
279 stated. In general, wherever a function or macro has an
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
280 <parameter>attr</parameter> or <parameter>__attr</parameter>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
281 parameter, then the contents of this string will be inserted into the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
282 tag being defined as HTML attributes. If it is a NULL or empty string
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
283 it will be ignored.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
284 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
285 </note>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
286
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
287 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
288 <title>HTTP Support</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
289 <programlisting width=72>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
290 void cyg_http_start( FILE *client, char *content_type, int content_length );
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
291 void cyg_http_finish( FILE *client );
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
292 #define html_begin(__client)
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
293 #define html_end( __client )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
294 </programlisting>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
295 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
296 The function <function>cyg_http_start()</function> generates a simple
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
297 HTTP response header containing the value of
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
298 <literal>CYGDAT_HTTPD_SERVER_ID</literal> in the &quot;Server&quot; field, and the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
299 values of <parameter>content_type</parameter> and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
300 <parameter>content_length</parameter> in the &quot;Content-type&quot;
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
301 and &quot;Content-length&quot; field respectively. The function
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
302 <function>cyg_http_finish()</function> just adds an extra newline to
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
303 the end of the output and then flushes it to force the data out to the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
304 client.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
305 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
306 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
307 The macro <literal>html_begin()</literal> generates an HTTP header
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
308 with a &quot;text/html&quot; content type followed by an opening
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
309 &quot;&lt;html&gt;&quot; tag. <literal>html_end()</literal> generates
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
310 a closing &quot;&lt;/html&gt;&quot; tag and calls
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
311 <function>cyg_http_finish()</function>.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
312 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
313 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
314
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
315 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
316 <title>General HTML Support</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
317 <programlisting width=72>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
318 void cyg_html_tag_begin( FILE *client, char *tag, char *attr );
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
319 void cyg_html_tag_end( FILE *client, char *tag );
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
320 #define html_tag_begin( __client, __tag, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
321 #define html_tag_end( __client, __tag )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
322 #define html_head( __client, __title, __meta )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
323 #define html_body_begin( __client, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
324 #define html_body_end( __client )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
325 #define html_heading( __client, __level, __heading )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
326 #define html_para_begin( __client, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
327 #define html_url( __client, __text, __link )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
328 #define html_image( __client, __source, __alt, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
329 </programlisting>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
330 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
331 The function <function>cyg_html_tag_begin()</function> generates an
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
332 opening tag with the given name. The function
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
333 <function>cyg_html_tag_end()</function> generates a closing tag with
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
334 the given name. The macros <literal>html_tag_begin()</literal> and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
335 <literal>html_tag_end</literal> are just wrappers for these functions.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
336 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
337 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
338 The macro <literal>html_head()</literal> generates an HTML header
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
339 section with <parameter>__title</parameter> as the title. The
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
340 <parameter>__meta</parameter> argument defines any meta tags that will
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
341 be inserted into the header. <literal>html_body_begin()</literal> and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
342 <literal>html_body_end</literal> generate HTML body begin and end
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
343 tags.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
344 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
345 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
346 <literal>html_heading()</literal> generates a complete HTML header
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
347 where <parameter>__level</parameter> is a numerical level, between 1
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
348 and 6, and <parameter>__heading</parameter> is the heading
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
349 text. <literal>html_para_begin()</literal> generates a paragraph
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
350 break.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
351 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
352 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
353 <literal>html_url()</literal> inserts a URL where
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
354 <parameter>__text</parameter> is the displayed text and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
355 <parameter>__link</parameter> is the URL of the linked
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
356 page. <literal>html_image()</literal> inserts an image tag where
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
357 <parameter>__source</parameter> is the URL of the image to be
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
358 included and <parameter>__alt</parameter> is the alternative text for
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
359 when the image is not displayed.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
360 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
361 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
362
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
363 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
364 <title>Table Support</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
365 <programlisting width=72>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
366 #define html_table_begin( __client, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
367 #define html_table_end( __client )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
368 #define html_table_header( __client, __content, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
369 #define html_table_row_begin( __client, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
370 #define html_table_row_end( __client )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
371 #define html_table_data_begin( __client, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
372 #define html_table_data_end( __client )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
373 </programlisting>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
374 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
375 <literal>html_table_begin()</literal> starts a table and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
376 <literal>html_table_end()</literal> end
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
377 it. <literal>html_table_header()</literal> generates a simple table
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
378 column header containg the string <parameter>__content</parameter>.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
379 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
380 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
381 <literal>html_table_row_begin()</literal> and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
382 <literal>html_table_row_end()</literal> begin and end a table row,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
383 and similarly <literal>html_table_data_begin()</literal> and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
384 <literal>html_table_data_end()</literal> begin and end a table
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
385 entry.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
386 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
387 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
388
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
389 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
390 <title>Forms Support</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
391 <programlisting width=72>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
392 #define html_form_begin( __client, __url, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
393 #define html_form_end( __client )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
394 #define html_form_input( __client, __type, __name, __value, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
395 #define html_form_input_radio( __client, __name, __value, __checked )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
396 #define html_form_input_checkbox( __client, __name, __value, __checked )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
397 #define html_form_input_hidden( __client, __name, __value )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
398 #define html_form_select_begin( __client, __name, __attr )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
399 #define html_form_option( __client, __value, __label, __selected )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
400 #define html_form_select_end( __client )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
401 void cyg_formdata_parse( char *data, char *list[], int size );
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
402 char *cyg_formlist_find( char *list[], char *name );
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
403 </programlisting>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
404 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
405 <literal>html_form_begin()</literal> begins a form, the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
406 <parameter>__url</parameter> argument is the value for the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
407 <literal>action</literal>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
408 attribute. <literal>html_form_end()</literal> ends the form.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
409 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
410 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
411 <literal>html_form_input()</literal> defines a general form input
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
412 element with the given type, name and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
413 value. <literal>html_form_input_radio</literal> creates a radio button
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
414 with the given name and value; the <parameter>__checked</parameter>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
415 argument is a boolean expression that is used to determine whether the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
416 <literal>checked</literal> attribute is added to the tag. Similarly
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
417 <literal>html_form_input_checkbox()</literal> defines a checkbox
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
418 element. <literal>html_form_input_hidden()</literal> defines a hidden
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
419 form element with the given name and value.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
420 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
421 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
422 <literal>html_form_select_begin()</literal> begins a multiple choice
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
423 menu with the given name. <literal>html_form_select_end()</literal>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
424 end it. <literal>html_form_option()</literal> defines a menu entry
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
425 with the given value and label; the <parameter>__selected</parameter>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
426 argument is a boolean expression controlling whether the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
427 <literal>selected</literal> attribute is added to the tag.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
428 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
429 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
430 <function>cyg_formdata_parse()</function> converts a form response
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
431 string into an <literal>NULL</literal>-terminated array of
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
432 &quot;name=value&quot; entries. The <parameter>data</parameter>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
433 argument is the string as passed to the handler function; note that
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
434 this string is not copied and will be updated in place to form the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
435 list entries. <parameter>list</parameter> is a pointer to an array of
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
436 character pointers, and is <parameter>size</parameter> elements long.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
437 <function>cyg_formlist_find()</function> searches a list generated by
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
438 <function>cyg_formdata_parse()</function> and returns a pointer to the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
439 value part of the string whose name part matches
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
440 <parameter>name</parameter>; if there is no match it will return
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
441 <literal>NULL</literal>.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
442 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
443 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
444
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
445 <sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
446 <title>Predefined Handlers</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
447 <programlisting width=72>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
448
1240
eeb14eae974b * src/httpd.c (cyg_httpd_server): Removed unused variable.
asl
parents: 1008
diff changeset
449 cyg_bool cyg_httpd_send_html( FILE *client, char *filename, char *request, void *arg );
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
450
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
451 typedef struct
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
452 {
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
453 char *content_type;
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
454 cyg_uint32 content_length;
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
455 cyg_uint8 *data;
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
456 } cyg_httpd_data;
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
457 #define CYG_HTTPD_DATA( __name, __type, __length, __data )
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
458
1240
eeb14eae974b * src/httpd.c (cyg_httpd_server): Removed unused variable.
asl
parents: 1008
diff changeset
459 cyg_bool cyg_httpd_send_data( FILE *client, char *filename, char *request, void *arg );
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
460
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
461 </programlisting>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
462 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
463 The HTTP server defines a couple of predefined handers to make it
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
464 easier to deliver simple, static content.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
465 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
466 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
467 <function>cyg_httpd_send_html()</function> takes a
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
468 <literal>NULL</literal>-terminated string as the argument and sends it
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
469 to the client with an HTTP header indicating that it is HTML. The
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
470 following is an example of its use:
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
471 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
472 <programlisting width=72>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
473
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
474 char cyg_html_message[] = "&lt;head&gt;&lt;title&gt;Welcome&lt;/title&gt;&lt;/head&gt;\n"
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
475 "&lt;body&gt;&lt;h2&gt;Welcome to my Web Page&lt;/h2&gt;&lt;/body&gt;\n"
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
476
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
477 CYG_HTTPD_TABLE_ENTRY( cyg_html_message_entry,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
478 "/message.html",
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
479 cyg_httpd_send_html,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
480 cyg_html_message );
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
481
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
482 </programlisting>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
483 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
484 <function>cyg_httpd_send_data()</function> Sends arbitrary data to the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
485 client. The argument is a pointer to a <type>cyg_httpd_data</type>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
486 structure that defines the content type and length of the data, and a
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
487 pointer to the data itself. The <literal>CYG_HTTPD_DATA()</literal>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
488 macro automates the definition of the structure. Here is a typical
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
489 example of its use:
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
490 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
491 <programlisting width=72>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
492
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
493 static cyg_uint8 ecos_logo_gif[] = {
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
494 ...
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
495 };
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
496
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
497 CYG_HTTPD_DATA( cyg_monitor_ecos_logo_data,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
498 "image/gif",
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
499 sizeof(ecos_logo_gif),
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
500 ecos_logo_gif );
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
501
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
502 CYG_HTTPD_TABLE_ENTRY( cyg_monitor_ecos_logo,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
503 "/monitor/ecos.gif",
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
504 cyg_httpd_send_data,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
505 &amp;cyg_monitor_ecos_logo_data );
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
506
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
507 </programlisting>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
508 </sect2>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
509
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
510 </sect1>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
511
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
512 <!-- =============================================================== -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
513
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
514 <sect1 id="net-httpd-monitor">
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
515 <title>System Monitor</title>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
516 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
517 Included in the HTTPD package is a simple System Monitor that is
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
518 intended to act as a test and an example of how to produce servers.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
519 It is also hoped that it might be of some use in and of itself.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
520 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
521 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
522 The System Monitor is intended to work in the background of any
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
523 application. Adding the network stack and the HTTPD package to any
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
524 configuration will enable the monitor by default. It may be disabled
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
525 by disabling the <literal>CYGPKG_HTTPD_MONITOR</literal> option.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
526 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
527 <para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
528 The monitor is intended to be simple and self-explanatory in use. It
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
529 consists of four main pages. The thread monitor page presents a table
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
530 of all current threads showing such things as id, state, priority,
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
531 name and stack dimensions. Clicking on the thread ID will link to a
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
532 thread edit page where the thread's state and priority may be
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
533 manipulated. The interrupt monitor just shows a table of the current
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
534 interrupts and indicates which are active. The memory monitor shows a
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
535 256 byte page of memory, with controls to change the base address and
1008
4ca8a5f30c03 * src/monitor.c (cyg_monitor_network): Added IPv6 information to
asl
parents: 468
diff changeset
536 display element size. Note: Accessing invalid memory locations can cause
4ca8a5f30c03 * src/monitor.c (cyg_monitor_network): Added IPv6 information to
asl
parents: 468
diff changeset
537 memory exceptions and the program to crash. The network monitor page shows
468
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
538 information extracted from the active network interfaces and
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
539 protocols. Finally, if kernel instrumentation is enabled, the
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
540 instrumentation page provides some controls over the instrumentation
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
541 mechanism, and displays the instrumentation buffer.
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
542 </para>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
543 </sect1>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
544
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
545 <!-- =============================================================== -->
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
546
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
547 </chapter>
ca4f29d41b18 Created new HTTPD package.
nickg
parents:
diff changeset
548 </part>