Add to git.
[pthrlib.git] / doc / http_request_time.3.html
1 <html>
2 <head>
3 <meta name="generator" content="groff -Thtml, see www.gnu.org">
4 <meta name="Content-Style" content="text/css">
5 <title>new_http_request</title>
6 </head>
7 <body>
8
9 <h1 align=center>new_http_request</h1>
10 <a href="#NAME">NAME</a><br>
11 <a href="#SYNOPSIS">SYNOPSIS</a><br>
12 <a href="#DESCRIPTION">DESCRIPTION</a><br>
13 <a href="#AUTHOR">AUTHOR</a><br>
14 <a href="#LICENSE">LICENSE</a><br>
15 <a href="#VERSION">VERSION</a><br>
16 <a href="#SEE ALSO">SEE ALSO</a><br>
17
18 <hr>
19 <!-- Creator     : groff version 1.17.2 -->
20 <!-- CreationDate: Fri Aug 30 16:16:22 2002 -->
21 <a name="NAME"></a>
22 <h2>NAME</h2>
23 <table width="100%" border=0 rules="none" frame="void"
24        cols="2" cellspacing="0" cellpadding="0">
25 <tr valign="top" align="left">
26 <td width="10%"></td><td width="90%">
27 new_http_request, http_request_time, http_request_url, http_request_path, http_request_query_string, http_request_method, http_request_method_string, http_request_is_HEAD, http_request_version, http_request_nr_headers, http_request_get_headers, http_request_get_header - functions for parsing HTTP requests</td></table>
28 <a name="SYNOPSIS"></a>
29 <h2>SYNOPSIS</h2>
30
31 <table width="100%" border=0 rules="none" frame="void"
32        cols="2" cellspacing="0" cellpadding="0">
33 <tr valign="top" align="left">
34 <td width="10%"></td><td width="90%">
35 <pre><b>#include &lt;pthr_http.h&gt;
36
37 http_request new_http_request (pseudothread, io_handle);
38 time_t http_request_time (http_request);
39 const char *http_request_url (http_request);
40 const char *http_request_path (http_request);
41 const char *http_request_query_string (http_request);
42 int http_request_method (http_request);
43 const char *http_request_method_string (http_request);
44 int http_request_is_HEAD (http_request);
45 void http_request_version (http_request, int *major, int *minor);
46 int http_request_nr_headers (http_request);
47 vector http_request_get_headers (http_request);
48 const char *http_request_get_header (http_request h, const char *key);
49 </b></pre></td></table>
50 <a name="DESCRIPTION"></a>
51 <h2>DESCRIPTION</h2>
52
53 <table width="100%" border=0 rules="none" frame="void"
54        cols="2" cellspacing="0" cellpadding="0">
55 <tr valign="top" align="left">
56 <td width="10%"></td><td width="90%">
57 These functions allow you to efficiently parse incoming HTTP
58 requests from conforming HTTP/0.9, HTTP/1.0 and HTTP/1.1
59 clients. The request parser understands GET, HEAD and POST
60 requests and conforms as far as possible to RFC
61 2616.</td></table>
62
63 <table width="100%" border=0 rules="none" frame="void"
64        cols="2" cellspacing="0" cellpadding="0">
65 <tr valign="top" align="left">
66 <td width="10%"></td><td width="90%">
67 <b>new_http_request</b> creates a new request object,
68 parsing the incoming request on the given <b>io_handle</b>.
69 If the stream closes at the beginning of the request the
70 function returns <b>NULL</b>. If the request is faulty, then
71 the library prints a message to syslog and throws an
72 exception by calling <b>pth_die(3)</b>. Otherwise it
73 initializes a complete <b>http_request</b> object and
74 returns it.</td></table>
75
76 <table width="100%" border=0 rules="none" frame="void"
77        cols="2" cellspacing="0" cellpadding="0">
78 <tr valign="top" align="left">
79 <td width="10%"></td><td width="90%">
80 <b>http_request_time</b> returns the timestamp of the
81 incoming request.</td></table>
82
83 <table width="100%" border=0 rules="none" frame="void"
84        cols="2" cellspacing="0" cellpadding="0">
85 <tr valign="top" align="left">
86 <td width="10%"></td><td width="90%">
87 <b>http_request_url</b> returns the complete URL of the
88 request. <b>http_request_path</b> returns just the path
89 component of the URL (ie. without the query string if there
90 was one). <b>http_request_query_string</b> returns just the
91 query string (for GET requests only). Do not do your own
92 parsing of query strings: there is a CGI library built into
93 pthrlib (see: <b>new_cgi(3)</b>).</td></table>
94
95 <table width="100%" border=0 rules="none" frame="void"
96        cols="2" cellspacing="0" cellpadding="0">
97 <tr valign="top" align="left">
98 <td width="10%"></td><td width="90%">
99 <b>http_request_method</b> returns the method, one of
100 <b>HTTP_METHOD_GET</b>, <b>HTTP_METHOD_HEAD</b> or
101 <b>HTTP_METHOD_POST</b>. <b>http_request_is_HEAD</b> is just
102 a quick way of testing if the method is a HEAD request.
103 <b>http_request_method_string</b> returns the method as a
104 string rather than a coded number.</td></table>
105
106 <table width="100%" border=0 rules="none" frame="void"
107        cols="2" cellspacing="0" cellpadding="0">
108 <tr valign="top" align="left">
109 <td width="10%"></td><td width="90%">
110 <b>http_request_version</b> returns the major and minor
111 numbers of the HTTP request (eg. major = 1, minor = 0 for a
112 HTTP/1.0 request).</td></table>
113
114 <table width="100%" border=0 rules="none" frame="void"
115        cols="2" cellspacing="0" cellpadding="0">
116 <tr valign="top" align="left">
117 <td width="10%"></td><td width="90%">
118 <b>http_request_nr_headers</b>,
119 <b>http_request_get_headers</b> and
120 <b>http_request_get_header</b> return the number of HTTP
121 headers, the list of HTTP headers and a particular HTTP
122 header (if it exists). <b>http_request_get_headers</b>
123 returns a <b>vector</b> or <b>struct http_header</b>. This
124 structure contains at least two fields called <b>key</b> and
125 <b>value</b>. HTTP header keys are case insensitive when
126 searching, and you will find that the list of keys returned
127 by <b>http_request_get_headers</b> has been converted to
128 lowercase.</td></table>
129 <a name="AUTHOR"></a>
130 <h2>AUTHOR</h2>
131
132 <table width="100%" border=0 rules="none" frame="void"
133        cols="2" cellspacing="0" cellpadding="0">
134 <tr valign="top" align="left">
135 <td width="10%"></td><td width="90%">
136 Richard Jones &lt;rich@annexia.org&gt;</td></table>
137 <a name="LICENSE"></a>
138 <h2>LICENSE</h2>
139
140 <table width="100%" border=0 rules="none" frame="void"
141        cols="2" cellspacing="0" cellpadding="0">
142 <tr valign="top" align="left">
143 <td width="10%"></td><td width="90%">
144 GNU LGPL (see http://www.gnu.org/)</td></table>
145 <a name="VERSION"></a>
146 <h2>VERSION</h2>
147
148 <table width="100%" border=0 rules="none" frame="void"
149        cols="2" cellspacing="0" cellpadding="0">
150 <tr valign="top" align="left">
151 <td width="10%"></td><td width="90%">
152 pthrlib-3.0.3</td></table>
153 <a name="SEE ALSO"></a>
154 <h2>SEE ALSO</h2>
155
156 <table width="100%" border=0 rules="none" frame="void"
157        cols="2" cellspacing="0" cellpadding="0">
158 <tr valign="top" align="left">
159 <td width="10%"></td><td width="90%">
160 <b>new_http_response(3)</b>, <b>new_cgi(3)</b>,
161 <b>new_pseudothread(3)</b>, <b>io_fdopen(3)</b>, RFC
162 2616.</td></table>
163 <hr>
164 </body>
165 </html>