httpRequest_8c-source.html
32.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>xmlrpc: reader/httpReader/httpRequest.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<h1>reader/httpReader/httpRequest.c</h1><a href="httpRequest_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include <string.h></span>
<a name="l00002"></a>00002 <span class="preprocessor">#include <stdlib.h></span>
<a name="l00003"></a>00003 <span class="preprocessor">#include <stdio.h></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include <ctype.h></span>
<a name="l00005"></a>00005
<a name="l00006"></a>00006 <span class="preprocessor">#include "../../include/appConfig.h"</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include "../../include/httpRequest.h"</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include "../../include/client.h"</span>
<a name="l00009"></a>00009
<a name="l00010"></a><a class="code" href="httpRequest_8c.html#5ff6e798033f03e74730e99f01936f84">00010</a> <span class="preprocessor">#define SPACE 0x20</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span>
<a name="l00012"></a>00012
<a name="l00013"></a><a class="code" href="httpRequest_8c.html#e7110ef069c94769a78296dc38ab86ca">00013</a> <span class="keywordtype">char</span> <a class="code" href="httpRequest_8h.html#e7110ef069c94769a78296dc38ab86ca">httpRequest</a>[8][8] = {
<a name="l00014"></a>00014 <span class="stringliteral">"OPTIONS"</span>,
<a name="l00015"></a>00015 <span class="stringliteral">"GET"</span>,
<a name="l00016"></a>00016 <span class="stringliteral">"HEAD"</span>,
<a name="l00017"></a>00017 <span class="stringliteral">"POST"</span>,
<a name="l00018"></a>00018 <span class="stringliteral">"PUT"</span>,
<a name="l00019"></a>00019 <span class="stringliteral">"DELETE"</span>,
<a name="l00020"></a>00020 <span class="stringliteral">"TRACE"</span>,
<a name="l00021"></a>00021 <span class="stringliteral">"CONNECT"</span>
<a name="l00022"></a>00022 };
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="comment">/*</span>
<a name="l00025"></a>00025 <span class="comment"> * Gedanken zum request einlese:</span>
<a name="l00026"></a>00026 <span class="comment"> * der client liest stumpf daten, außerdem implementiert er eine Methode um die</span>
<a name="l00027"></a>00027 <span class="comment"> * erste Zeile aus dem readbuffer zu entfernen.</span>
<a name="l00028"></a>00028 <span class="comment"> * Des weiteren eine Methode getLine die NULL zurück gibt wenn noch keine Zeile</span>
<a name="l00029"></a>00029 <span class="comment"> * komplett ist, ansonsten einen Pointer auf diese.</span>
<a name="l00030"></a>00030 <span class="comment"> * Der servercode triggert das Daten lesen des client, versucht dann die erste</span>
<a name="l00031"></a>00031 <span class="comment"> * Zeile zu lesen und gibt diese im erfolgsfall an den httpCode weiter um</span>
<a name="l00032"></a>00032 <span class="comment"> * dann wenn dieser ein OK gibt die erste Zeile über den clientCode wieder zu entfernen.</span>
<a name="l00033"></a>00033 <span class="comment"> * Leere Zeile vor der request line werden ignoriert.</span>
<a name="l00034"></a>00034 <span class="comment"> * Ebenso leere Zailen nachdem der request komplett eingelesen ist.</span>
<a name="l00035"></a>00035 <span class="comment"> * Nachdem alle Header Zeile eingelesen wurden...d.H. sobald eine leere Header Zeile</span>
<a name="l00036"></a>00036 <span class="comment"> * gelesen wurde wird exakt bodyLength vom client versucht zu lesen...hierbei</span>
<a name="l00037"></a>00037 <span class="comment"> * können die Daten die von client kommen in den body buffer übertragen werden.</span>
<a name="l00038"></a>00038 <span class="comment"> * Dabei kann im client code der buffer immer entsprechend zurück gesetzt werden.</span>
<a name="l00039"></a>00039 <span class="comment"> */</span>
<a name="l00040"></a>00040 <span class="keywordtype">int</span>
<a name="l00041"></a><a class="code" href="httpRequest_8c.html#c96f6dae9ced89eb2ae8ac556918e367">00041</a> <a class="code" href="httpRequest_8c.html#c96f6dae9ced89eb2ae8ac556918e367">httpHeaderGetLine</a>(<a class="code" href="structtHttpHeader.html">tHttpHeader</a> * header, <span class="keywordtype">char</span> ** buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> * readPos)
<a name="l00042"></a>00042 {
<a name="l00043"></a>00043 <span class="keywordflow">return</span> 1;
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045
<a name="l00046"></a>00046 <span class="keywordtype">void</span>
<a name="l00047"></a><a class="code" href="httpRequest_8c.html#e18ae9e899c3c951308bb2ec4bd810f5">00047</a> <a class="code" href="httpRequest_8h.html#b7ea84417c64cc894ef20f3fad58832f">httpHeaderParseRequestLine</a>(<a class="code" href="structtHttpHeader.html">tHttpHeader</a> * header, <span class="keyword">const</span> <span class="keywordtype">char</span> * line, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len)
<a name="l00048"></a>00048 {
<a name="l00049"></a>00049 }
<a name="l00050"></a>00050
<a name="l00051"></a>00051 <span class="keywordtype">int</span>
<a name="l00052"></a><a class="code" href="httpRequest_8c.html#d5d9232083e5890588d5e1840341a48b">00052</a> <a class="code" href="httpRequest_8h.html#91e1c62216e1370b68a87ffc8b120f0d">httpHeaderIsComplete</a>(<a class="code" href="structtHttpHeader.html">tHttpHeader</a> * header)
<a name="l00053"></a>00053 {
<a name="l00054"></a>00054 <span class="keywordflow">if</span> (NULL == header-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#418658e78fa3e0e0e5fbd8f693104558">method</a>) {
<a name="l00055"></a>00055 <span class="keywordflow">return</span> 0;
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057
<a name="l00058"></a>00058 <span class="keywordflow">return</span> 1;
<a name="l00059"></a>00059 }
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>
<a name="l00062"></a><a class="code" href="httpRequest_8c.html#29982601e2121cd75800202f5716c7f5">00062</a> <a class="code" href="httpRequest_8h.html#99eb3b2c1e06ee773fd3bb7da7e98ece">httpHeaderIsStarted</a>(<a class="code" href="structtHttpHeader.html">tHttpHeader</a> * header) {
<a name="l00063"></a>00063 <span class="keywordflow">return</span> 1;
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00067"></a>00067 httpRequestStrip(<span class="keywordtype">char</span> ** buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> * readPos)
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069 <span class="keywordtype">char</span> * <a class="code" href="serverRun_8c.html#1e60190f250d3f699f3671c759e6fe36">end</a> = *buffer;
<a name="l00070"></a>00070
<a name="l00071"></a>00071 <span class="comment">/* remove all surrounding CRLF */</span>
<a name="l00072"></a>00072 <span class="keywordflow">while</span> ((<span class="charliteral">'\r'</span> == *end || <span class="charliteral">'\n'</span> == *end) && *end) {
<a name="l00073"></a>00073 end++;
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075
<a name="l00076"></a>00076 <span class="keywordflow">if</span> (end != *buffer) {
<a name="l00077"></a>00077 memmove(*buffer, end, *readPos - (end - *buffer));
<a name="l00078"></a>00078 memset(*buffer, 0, end - *buffer);
<a name="l00079"></a>00079
<a name="l00080"></a>00080 *readPos -= (end - * buffer);
<a name="l00081"></a>00081 }
<a name="l00082"></a>00082 }
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <span class="keywordtype">int</span>
<a name="l00085"></a><a class="code" href="httpRequest_8c.html#fd4f839160f6d97ad28e05ee1ce81188">00085</a> <a class="code" href="httpRequest_8h.html#07afde622816238d4424591269f5616a">httpHeaderGet</a>(<span class="keywordtype">char</span> ** buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> * readPos, <a class="code" href="structtHttpHeader.html">tHttpHeader</a> * request)
<a name="l00086"></a>00086 {
<a name="l00087"></a>00087 <span class="keywordtype">char</span> * end = *buffer;
<a name="l00088"></a>00088 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> readPosNew;
<a name="l00089"></a>00089
<a name="l00090"></a>00090 httpRequestStrip(buffer, readPos);
<a name="l00091"></a>00091 end = strstr(*buffer, <span class="stringliteral">"\r\n\r\n"</span>);
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <span class="comment">/* get header if not already read and complete */</span>
<a name="l00094"></a>00094 <span class="keywordflow">if</span> (!<a class="code" href="httpRequest_8h.html#91e1c62216e1370b68a87ffc8b120f0d">httpHeaderIsComplete</a>(request) && NULL != end) {
<a name="l00095"></a>00095 <span class="comment">/* get request line */</span>
<a name="l00096"></a>00096 <span class="keywordtype">char</span> * methodEnd = strchr(*buffer, <a class="code" href="httpRequest_8c.html#5ff6e798033f03e74730e99f01936f84">SPACE</a>);
<a name="l00097"></a>00097 <span class="keywordtype">char</span> * uriEnd = strchr(methodEnd + 1, <a class="code" href="httpRequest_8c.html#5ff6e798033f03e74730e99f01936f84">SPACE</a>);
<a name="l00098"></a>00098 <span class="keywordtype">char</span> * lineEnd = strstr(*buffer, <span class="stringliteral">"\r\n"</span>);
<a name="l00099"></a>00099
<a name="l00100"></a>00100 request-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#418658e78fa3e0e0e5fbd8f693104558">method</a> =
<a name="l00101"></a>00101 calloc(methodEnd-*buffer+1, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));
<a name="l00102"></a>00102 request-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#5748787454dc1cc0dc06240e2890e025">requestUri</a> =
<a name="l00103"></a>00103 calloc(uriEnd-methodEnd, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));
<a name="l00104"></a>00104 request-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#9e9dad5c7e7851b4a5e5b8ab8837a72b">httpVersion</a> =
<a name="l00105"></a>00105 calloc(lineEnd-uriEnd, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));
<a name="l00106"></a>00106
<a name="l00107"></a>00107 sscanf(*buffer, <span class="stringliteral">"%s %s %s\r\n"</span>,
<a name="l00108"></a>00108 request-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#418658e78fa3e0e0e5fbd8f693104558">method</a>,
<a name="l00109"></a>00109 request-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#5748787454dc1cc0dc06240e2890e025">requestUri</a>,
<a name="l00110"></a>00110 request-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#9e9dad5c7e7851b4a5e5b8ab8837a72b">httpVersion</a>);
<a name="l00111"></a>00111
<a name="l00112"></a>00112 readPosNew = (*buffer + *readPos) - lineEnd - 2;
<a name="l00113"></a>00113 memmove(*buffer, lineEnd + 2, readPosNew);
<a name="l00114"></a>00114 memset(*buffer + readPosNew, 0, *readPos - readPosNew);
<a name="l00115"></a>00115 *readPos = readPosNew;
<a name="l00116"></a>00116
<a name="l00117"></a>00117 <span class="comment">/* get all header lines */</span>
<a name="l00118"></a>00118 <span class="keywordflow">do</span> {
<a name="l00119"></a>00119 <span class="keywordtype">char</span> * keyEnd = strchr(*buffer, <span class="charliteral">':'</span>);
<a name="l00120"></a>00120
<a name="l00121"></a>00121 lineEnd = strstr(*buffer, <span class="stringliteral">"\r\n"</span>);
<a name="l00122"></a>00122
<a name="l00123"></a>00123 <span class="keywordflow">if</span> (lineEnd != *buffer) {
<a name="l00124"></a>00124 <a class="code" href="structtHttpHeaderLine.html">tHttpHeaderLine</a> * actHeader;
<a name="l00125"></a>00125 <span class="keywordtype">char</span> * actKey = NULL;
<a name="l00126"></a>00126
<a name="l00127"></a>00127 request-><a class="code" href="structtHttpHeader.html#40e3a997c2da1c432caef805ff150e42">headersCount</a> += 1;
<a name="l00128"></a>00128
<a name="l00129"></a>00129 request-><a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a> = realloc(request-><a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>,
<a name="l00130"></a>00130 request-><a class="code" href="structtHttpHeader.html#40e3a997c2da1c432caef805ff150e42">headersCount</a> * <span class="keyword">sizeof</span>(<a class="code" href="structtHttpHeaderLine.html">tHttpHeaderLine</a>));
<a name="l00131"></a>00131 actHeader = &(request-><a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[request-><a class="code" href="structtHttpHeader.html#40e3a997c2da1c432caef805ff150e42">headersCount</a>-1]);
<a name="l00132"></a>00132 memset(actHeader, 0, <span class="keyword">sizeof</span>(<a class="code" href="structtHttpHeaderLine.html">tHttpHeaderLine</a>));
<a name="l00133"></a>00133
<a name="l00134"></a>00134 actKey = actHeader-><a class="code" href="structtHttpHeaderLine.html#0b7fdfe2d665663b34ab17f843bdd362">key</a> = calloc(keyEnd-*buffer+1, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));
<a name="l00135"></a>00135 actHeader-><a class="code" href="structtHttpHeaderLine.html#20a63b6ab6476fd27b5ec5438150dba9">value</a> = calloc(lineEnd-keyEnd-1, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));
<a name="l00136"></a>00136
<a name="l00137"></a>00137 sscanf(*buffer, <span class="stringliteral">"%[^:]:%s\r\n"</span>,
<a name="l00138"></a>00138 actHeader-><a class="code" href="structtHttpHeaderLine.html#0b7fdfe2d665663b34ab17f843bdd362">key</a>, actHeader-><a class="code" href="structtHttpHeaderLine.html#20a63b6ab6476fd27b5ec5438150dba9">value</a>);
<a name="l00139"></a>00139 <span class="comment">//while (NULL != actKey && *actKey != '\0' && (*actKey = tolower(*(actKey++)))); // strtolower</span>
<a name="l00140"></a>00140 <span class="keywordflow">for</span> (; NULL != actKey && *actKey != <span class="charliteral">'\0'</span>; actKey++) {
<a name="l00141"></a>00141 *actKey = tolower(*actKey);
<a name="l00142"></a>00142 }
<a name="l00143"></a>00143
<a name="l00144"></a>00144 <span class="keywordflow">if</span> (0 == strncmp(<span class="stringliteral">"content-length"</span>, actHeader-><a class="code" href="structtHttpHeaderLine.html#0b7fdfe2d665663b34ab17f843bdd362">key</a>, strlen(actHeader-><a class="code" href="structtHttpHeaderLine.html#0b7fdfe2d665663b34ab17f843bdd362">key</a>))) {
<a name="l00145"></a>00145 request-><a class="code" href="structtHttpHeader.html#4c362cb9ed28c3c0ee28371cb28c2460">bodyLength</a> = atoi(actHeader-><a class="code" href="structtHttpHeaderLine.html#20a63b6ab6476fd27b5ec5438150dba9">value</a>);
<a name="l00146"></a>00146 }
<a name="l00147"></a>00147 }
<a name="l00148"></a>00148
<a name="l00149"></a>00149 readPosNew = (*buffer + *readPos) - lineEnd - 2;
<a name="l00150"></a>00150 memmove(*buffer, lineEnd + 2, readPosNew);
<a name="l00151"></a>00151 memset(*buffer + readPosNew, 0, *readPos - readPosNew);
<a name="l00152"></a>00152 *readPos = readPosNew;
<a name="l00153"></a>00153 } <span class="keywordflow">while</span> (lineEnd != *buffer);
<a name="l00154"></a>00154
<a name="l00155"></a>00155 <span class="keywordflow">return</span> request-><a class="code" href="structtHttpHeader.html#4c362cb9ed28c3c0ee28371cb28c2460">bodyLength</a>;
<a name="l00156"></a>00156 }
<a name="l00157"></a>00157
<a name="l00158"></a>00158 <span class="keywordflow">return</span> 0;
<a name="l00159"></a>00159 }
<a name="l00160"></a>00160
<a name="l00161"></a>00161 <span class="keywordtype">int</span>
<a name="l00162"></a><a class="code" href="httpRequest_8c.html#9a6b00ad980ca9a2c5023ec1a802106b">00162</a> <a class="code" href="httpRequest_8h.html#59d765731e7d39f5583ef175950becb1">getHttpRequest</a>(<span class="keywordtype">char</span> ** buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> * readPos, <a class="code" href="structtHttpRequest.html">tHttpRequest</a> * request)
<a name="l00163"></a>00163 {
<a name="l00164"></a>00164 <span class="comment">/* get body if header is read and body incomplete */</span>
<a name="l00165"></a>00165 <span class="keywordflow">if</span> (request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#4c362cb9ed28c3c0ee28371cb28c2460">bodyLength</a> != request-><a class="code" href="structtHttpRequest.html#208d984f6996b3b75579b9d7f9583231">length</a>) {
<a name="l00166"></a>00166 <span class="keywordtype">size_t</span> size = <a class="code" href="appConfig_8h.html#74e75242132eaabbc1c512488a135926">MIN</a>(
<a name="l00167"></a>00167 request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#4c362cb9ed28c3c0ee28371cb28c2460">bodyLength</a> - request-><a class="code" href="structtHttpRequest.html#208d984f6996b3b75579b9d7f9583231">length</a>,
<a name="l00168"></a>00168 *readPos);
<a name="l00169"></a>00169
<a name="l00170"></a>00170 <span class="keywordflow">if</span> (0 != size) {
<a name="l00171"></a>00171 <span class="keywordflow">if</span> (NULL == request-><a class="code" href="structtHttpRequest.html#3bafedaca9066375ffc720da29235ae2">body</a>) {
<a name="l00172"></a>00172 request-><a class="code" href="structtHttpRequest.html#3bafedaca9066375ffc720da29235ae2">body</a> = calloc(request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#4c362cb9ed28c3c0ee28371cb28c2460">bodyLength</a>, <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174
<a name="l00175"></a>00175 memcpy(request-><a class="code" href="structtHttpRequest.html#3bafedaca9066375ffc720da29235ae2">body</a> + request-><a class="code" href="structtHttpRequest.html#208d984f6996b3b75579b9d7f9583231">length</a>, *buffer, size);
<a name="l00176"></a>00176 memmove(*buffer, *buffer + size, *readPos - size);
<a name="l00177"></a>00177 memset(*buffer + (*readPos - size), 0, size);
<a name="l00178"></a>00178 *readPos -= size;
<a name="l00179"></a>00179 request-><a class="code" href="structtHttpRequest.html#208d984f6996b3b75579b9d7f9583231">length</a> += size;
<a name="l00180"></a>00180 }
<a name="l00181"></a>00181 }
<a name="l00182"></a>00182
<a name="l00183"></a>00183 <span class="keywordflow">return</span> 0;
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185
<a name="l00186"></a>00186 <span class="keywordtype">void</span>
<a name="l00187"></a><a class="code" href="httpRequest_8c.html#86d86da69aefe2067f750c80e626de7c">00187</a> <a class="code" href="httpRequest_8h.html#b55d3458cc9e50ef2a22731d910c6385">freeHttpHeader</a>(<a class="code" href="structtHttpHeader.html">tHttpHeader</a> * header) {
<a name="l00188"></a>00188 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00189"></a>00189
<a name="l00190"></a>00190 <span class="keywordflow">if</span> (NULL != header-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#418658e78fa3e0e0e5fbd8f693104558">method</a>) {
<a name="l00191"></a>00191 free(header-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#418658e78fa3e0e0e5fbd8f693104558">method</a>);
<a name="l00192"></a>00192 }
<a name="l00193"></a>00193 <span class="keywordflow">if</span> (NULL != header-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#5748787454dc1cc0dc06240e2890e025">requestUri</a>) {
<a name="l00194"></a>00194 free(header-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#5748787454dc1cc0dc06240e2890e025">requestUri</a>);
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196 <span class="keywordflow">if</span> (NULL != header-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#9e9dad5c7e7851b4a5e5b8ab8837a72b">httpVersion</a>) {
<a name="l00197"></a>00197 free(header-><a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#9e9dad5c7e7851b4a5e5b8ab8837a72b">httpVersion</a>);
<a name="l00198"></a>00198 }
<a name="l00199"></a>00199
<a name="l00200"></a>00200 <span class="keywordflow">for</span> (i=0; i<header-><a class="code" href="structtHttpHeader.html#40e3a997c2da1c432caef805ff150e42">headersCount</a>; i++) {
<a name="l00201"></a>00201 <span class="keywordflow">if</span> (NULL != header-><a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[i].<a class="code" href="structtHttpHeaderLine.html#0b7fdfe2d665663b34ab17f843bdd362">key</a>) {
<a name="l00202"></a>00202 free(header-><a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[i].<a class="code" href="structtHttpHeaderLine.html#0b7fdfe2d665663b34ab17f843bdd362">key</a>);
<a name="l00203"></a>00203 }
<a name="l00204"></a>00204 <span class="keywordflow">if</span> (NULL != header-><a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[i].<a class="code" href="structtHttpHeaderLine.html#20a63b6ab6476fd27b5ec5438150dba9">value</a>) {
<a name="l00205"></a>00205 free(header-><a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[i].<a class="code" href="structtHttpHeaderLine.html#20a63b6ab6476fd27b5ec5438150dba9">value</a>);
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207 }
<a name="l00208"></a>00208
<a name="l00209"></a>00209 <span class="keywordflow">if</span> (NULL != header-><a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>) {
<a name="l00210"></a>00210 free(header-><a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>);
<a name="l00211"></a>00211 }
<a name="l00212"></a>00212
<a name="l00213"></a>00213 memset (header, 0, <span class="keyword">sizeof</span> (<a class="code" href="structtHttpHeader.html">tHttpHeader</a>));
<a name="l00214"></a>00214 }
<a name="l00215"></a>00215
<a name="l00216"></a>00216 <span class="keywordtype">void</span>
<a name="l00217"></a><a class="code" href="httpRequest_8c.html#d1d9e65b1761d1d5f809314b4b05e772">00217</a> <a class="code" href="httpRequest_8h.html#1bba1865657c64c0e1971a45ee6117ab">freeHttpRequest</a>(<a class="code" href="structtHttpRequest.html">tHttpRequest</a> * request) {
<a name="l00218"></a>00218 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00219"></a>00219
<a name="l00220"></a>00220 <span class="keywordflow">if</span> (NULL != request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#418658e78fa3e0e0e5fbd8f693104558">method</a>) {
<a name="l00221"></a>00221 free(request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#418658e78fa3e0e0e5fbd8f693104558">method</a>);
<a name="l00222"></a>00222 request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#418658e78fa3e0e0e5fbd8f693104558">method</a> = NULL;
<a name="l00223"></a>00223 }
<a name="l00224"></a>00224 <span class="keywordflow">if</span> (NULL != request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#5748787454dc1cc0dc06240e2890e025">requestUri</a>) {
<a name="l00225"></a>00225 free(request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#5748787454dc1cc0dc06240e2890e025">requestUri</a>);
<a name="l00226"></a>00226 request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#5748787454dc1cc0dc06240e2890e025">requestUri</a> = NULL;
<a name="l00227"></a>00227 }
<a name="l00228"></a>00228 <span class="keywordflow">if</span> (NULL != request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#9e9dad5c7e7851b4a5e5b8ab8837a72b">httpVersion</a>) {
<a name="l00229"></a>00229 free(request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#9e9dad5c7e7851b4a5e5b8ab8837a72b">httpVersion</a>);
<a name="l00230"></a>00230 request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#d624a9ea5e703b2e8cd812415e28dfc7">req</a>.<a class="code" href="structtRequestLine.html#9e9dad5c7e7851b4a5e5b8ab8837a72b">httpVersion</a> = NULL;
<a name="l00231"></a>00231 }
<a name="l00232"></a>00232
<a name="l00233"></a>00233 <span class="keywordflow">for</span> (i=0; i<request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#40e3a997c2da1c432caef805ff150e42">headersCount</a>; i++) {
<a name="l00234"></a>00234 <span class="keywordflow">if</span> (NULL != request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[i].<a class="code" href="structtHttpHeaderLine.html#0b7fdfe2d665663b34ab17f843bdd362">key</a>) {
<a name="l00235"></a>00235 free(request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[i].<a class="code" href="structtHttpHeaderLine.html#0b7fdfe2d665663b34ab17f843bdd362">key</a>);
<a name="l00236"></a>00236 request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[i].<a class="code" href="structtHttpHeaderLine.html#0b7fdfe2d665663b34ab17f843bdd362">key</a> = NULL;
<a name="l00237"></a>00237 }
<a name="l00238"></a>00238 <span class="keywordflow">if</span> (NULL != request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[i].<a class="code" href="structtHttpHeaderLine.html#20a63b6ab6476fd27b5ec5438150dba9">value</a>) {
<a name="l00239"></a>00239 free(request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[i].<a class="code" href="structtHttpHeaderLine.html#20a63b6ab6476fd27b5ec5438150dba9">value</a>);
<a name="l00240"></a>00240 request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>[i].<a class="code" href="structtHttpHeaderLine.html#20a63b6ab6476fd27b5ec5438150dba9">value</a> = NULL;
<a name="l00241"></a>00241 }
<a name="l00242"></a>00242 }
<a name="l00243"></a>00243
<a name="l00244"></a>00244 <span class="keywordflow">if</span> (NULL != request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>) {
<a name="l00245"></a>00245 free(request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a>);
<a name="l00246"></a>00246 request-><a class="code" href="structtHttpRequest.html#9936369fb110812f1a4b7fc31a0dc755">header</a>.<a class="code" href="structtHttpHeader.html#e44e0aa6e7494921acad1a07eaaecb3d">headers</a> = NULL;
<a name="l00247"></a>00247 }
<a name="l00248"></a>00248
<a name="l00249"></a>00249 <span class="keywordflow">if</span> (NULL != request-><a class="code" href="structtHttpRequest.html#3bafedaca9066375ffc720da29235ae2">body</a>) {
<a name="l00250"></a>00250 free(request-><a class="code" href="structtHttpRequest.html#3bafedaca9066375ffc720da29235ae2">body</a>);
<a name="l00251"></a>00251 request-><a class="code" href="structtHttpRequest.html#3bafedaca9066375ffc720da29235ae2">body</a> = NULL;
<a name="l00252"></a>00252 }
<a name="l00253"></a>00253
<a name="l00254"></a>00254 memset (request, 0, <span class="keyword">sizeof</span> (<a class="code" href="structtHttpRequest.html">tHttpRequest</a>));
<a name="l00255"></a>00255 }
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Oct 10 01:24:35 2010 for xmlrpc by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>