src/server/protocol.c

Wed, 28 Dec 2011 22:02:08 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 28 Dec 2011 22:02:08 +0100
changeset 8
f4d56bf9de40
parent 7
3c2ed7a7a5fd
child 9
30e51941a673
permissions
-rw-r--r--

Added request body reader

4
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2011 Olaf Wintermann. All rights reserved.
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include "protocol.h"
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include "pblock.h"
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "pool.h"
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "session.h"
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "io.h"
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 void protocol_status(Session *sn, Request *rq, int n, const char *m) {
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 rq->status_num = n;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 const char *msg = m ? m : protocol_status_message(n);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 pb_param *pp = pblock_removekey(pb_key_status, rq->srvhdrs);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 if (pp != NULL) {
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 param_free(pp);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 }
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 pp = pblock_key_param_create(rq->srvhdrs, pb_key_status, msg, strlen(msg));
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 pblock_kpinsert(pb_key_status, pp, rq->srvhdrs);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 }
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 /*
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 * http_status_message from Open Webserver (frame/http.cpp)
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 * TODO: replace, use sstr_t
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 NSAPI_PUBLIC const char * protocol_status_message (int code)
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 {
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 const char *r;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 switch (code)
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 {
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 case PROTOCOL_CONTINUE : // 100
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 r = "Continue";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 case PROTOCOL_SWITCHING: //101
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 r = "Switching Protocols";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 case PROTOCOL_OK: // 200
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 r = "OK";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 case PROTOCOL_CREATED: // 201
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 r = "Created";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 case PROTOCOL_ACCEPTED: // 202
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 r = "Accepted";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 case PROTOCOL_NONAUTHORITATIVE: // 203
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 r = "Non-Authoritative Information";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 case PROTOCOL_NO_CONTENT: //204
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 /* There is another define to PROTOCOL_NO_RESPONSE for 204 in nsapi.h
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 The spec maps this to No Content.
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 Hence cahnging this to No Content
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 r = "No Content";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 case PROTOCOL_RESET_CONTENT: // 205
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 r = "Reset Content";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 case PROTOCOL_PARTIAL_CONTENT: // 206
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 r = "Partial Content";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 case PROTOCOL_MULTI_STATUS: // 207
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 r = "Multi Status";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 case PROTOCOL_MULTIPLE_CHOICES: // 300
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 r = "Multiple Choices";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 case PROTOCOL_MOVED_PERMANENTLY: // 301
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 r = "Moved Permanently";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 case PROTOCOL_REDIRECT: // 302
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 r = "Moved Temporarily"; /* The spec actually says "Found" */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 case PROTOCOL_SEE_OTHER: // 303
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 r = "See Other";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 case PROTOCOL_NOT_MODIFIED: // 304
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 r = "Use local copy"; /* The spec actually says "Not Modified" */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 case PROTOCOL_USE_PROXY: // 305
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 r = "Use Proxy";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 case PROTOCOL_TEMPORARY_REDIRECT: // 307
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 r = "Temporary Redirect";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 case PROTOCOL_BAD_REQUEST: // 400
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 r = "Bad request";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 case PROTOCOL_UNAUTHORIZED: // 401
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 r = "Unauthorized";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 case PROTOCOL_PAYMENT_REQUIRED: // 402
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 r = "Payment Required";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 case PROTOCOL_FORBIDDEN: // 403
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 r = "Forbidden";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 case PROTOCOL_NOT_FOUND: // 404
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 r = "Not found";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 case PROTOCOL_METHOD_NOT_ALLOWED: // 405 /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 r = "Method Not Allowed";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 case PROTOCOL_NOT_ACCEPTABLE: // 406 /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 r = "Not Acceptable";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 case PROTOCOL_PROXY_UNAUTHORIZED: // 407
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 r = "Proxy Authentication Required";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 case PROTOCOL_REQUEST_TIMEOUT: // 408 /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 r = "Request Timeout";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 case PROTOCOL_CONFLICT: // 409
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 r = "Conflict"; /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 case PROTOCOL_GONE: // 410
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 r = "Gone"; /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 case PROTOCOL_LENGTH_REQUIRED: // 411 /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 r = "Length Required";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 case PROTOCOL_PRECONDITION_FAIL: // 412 /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 r = "Precondition Failed";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 case PROTOCOL_ENTITY_TOO_LARGE: // 413 /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 r = "Request Entity Too Large";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 case PROTOCOL_URI_TOO_LARGE: // 414 /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 r = "Request-URI Too Large";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 case PROTOCOL_UNSUPPORTED_MEDIA_TYPE: // 415
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 r = "Unsupported Media Type";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 case PROTOCOL_REQUESTED_RANGE_NOT_SATISFIABLE: // 416
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 r = "Requested range not satisfiable";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 case PROTOCOL_EXPECTATION_FAILED: // 417
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 r = "Expectation Failed";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 case PROTOCOL_LOCKED: // 423
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 r = "Locked";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 case PROTOCOL_FAILED_DEPENDENCY: // 424
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 r = "Failed Dependency";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 case PROTOCOL_SERVER_ERROR: // 500
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 r = "Server Error"; /* The spec actually says "Internal Server Error" */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 case PROTOCOL_NOT_IMPLEMENTED: // 501
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 r = "Not Implemented";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 case PROTOCOL_BAD_GATEWAY: // 502
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 r = "Bad Gateway";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 case PROTOCOL_SERVICE_UNAVAILABLE: // 503
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 r = "Service Unavailable";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 case PROTOCOL_GATEWAY_TIMEOUT: // 504 /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 r = "Gateway Timeout";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 case PROTOCOL_VERSION_NOT_SUPPORTED: // 505 /* HTTP/1.1 */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 r = "HTTP Version Not Supported";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197 case PROTOCOL_INSUFFICIENT_STORAGE: // 507
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 r = "Insufficient Storage";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200 default:
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 switch (code / 100)
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 {
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 case 1:
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 r = "Information";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 case 2:
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 r = "Success";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 case 3:
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 r = "Redirect";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 case 4:
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 r = "Client error";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 case 5:
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 r = "Server error";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 default:
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 r = "Unknown reason";
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 }
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 break;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 }
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 return r;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 }
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 void add_http_status_line(iovec_buf_t *out, Request *rq) {
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 iovec_buf_write(out, "HTTP/1.1 ", 9);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 char *status_code_str = pool_malloc(out->pool, 8);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 int sc_len = snprintf(status_code_str, 8, "%d ", rq->status_num);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 iovec_buf_write(out, status_code_str, sc_len);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 char *scmsg = pblock_findkeyval(pb_key_status, rq->srvhdrs);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 iovec_buf_write(out, scmsg, strlen(scmsg));
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 iovec_buf_write(out, "\r\n", 2);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 }
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241
7
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
242 void add_http_response_header(iovec_buf_t *out, Request *rq) {
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
243 pblock *h = rq->srvhdrs;
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
244 pb_entry *p;
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
245
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
246 for(int i=0;i<h->hsize;i++) {
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
247 p = h->ht[i];
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
248 while(p != NULL) {
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
249 /* from http.cpp */
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
250 const pb_key *key = PARAM_KEY(p->param);
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
251 if (key == pb_key_status || key == pb_key_server || key == pb_key_date) {
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
252 /* Skip internal Status:, Server:, and Date: information */
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
253 p = p->next;
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
254 continue;
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
255 }
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
256 /* end http.cpp */
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
257
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
258 char *name = p->param->name;
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
259 char *value = p->param->value;
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
260
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
261 /* make first char of name uppercase */
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
262 if(name[0] > 90) {
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
263 name[0] -= 32;
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
264 }
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
265
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
266 iovec_buf_write(out, name, strlen(name));
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
267 iovec_buf_write(out, ": ", 2);
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
268 iovec_buf_write(out, value, strlen(value));
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
269 iovec_buf_write(out, "\r\n", 2);
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
270
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
271 p = p->next;
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
272 }
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
273 }
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
274 }
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
275
4
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 int http_start_response(Session *sn, Request *rq) {
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 int fd = ((SystemIOStream*)sn->csd)->fd;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 /* set socket blocking */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 int flags;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 flags = fcntl(fd, F_GETFL, 0);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 fcntl(fd, F_SETFL, flags ^ O_NONBLOCK);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 /* iovec output buffer */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 iovec_buf_t *out = iovec_buf_create(sn->pool);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 /* add the http status line to the output buffer */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288 add_http_status_line(out, rq);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 /* add server header */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 iovec_buf_write(out, "Server: WS uap-dev\r\n", 20);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292
7
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
293 /* add header from rq->srvhdrs */
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
294 add_http_response_header(out, rq);
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
295
3c2ed7a7a5fd request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
296 /* response header end */
4
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 iovec_buf_write(out, "\r\n", 2);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 /* flush buffer to the socket */
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 iovec_buf_flush(out, fd);
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 rq->senthdrs = 1;
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 }
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304
998844b5ed25 Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305

mercurial