Sun, 07 Aug 2022 13:46:43 +0200
add new dav config element
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 | * |
44
3da1f7b6847f
added some error messages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
4 | * Copyright 2013 Olaf Wintermann. All rights reserved. |
4
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 | |
121
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
31 | #include "session.h" |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
32 | #include "httplistener.h" |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
33 | #include "request.h" |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
34 | |
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
11
diff
changeset
|
35 | #include "../util/pblock.h" |
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
11
diff
changeset
|
36 | #include "../util/pool.h" |
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
11
diff
changeset
|
37 | #include "../util/io.h" |
103
d3b514e2ddbd
added date header to response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
38 | #include "../util/util.h" |
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
11
diff
changeset
|
39 | #include "../util/strbuf.h" |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | |
121
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
41 | #define HTTP_SCHEME "http" |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
42 | #define HTTPS_SCHEME "https" |
4
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 | 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
|
45 | rq->status_num = n; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | const char *msg = m ? m : protocol_status_message(n); |
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 | pb_param *pp = pblock_removekey(pb_key_status, rq->srvhdrs); |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | if (pp != NULL) { |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | param_free(pp); |
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 | 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
|
55 | pblock_kpinsert(pb_key_status, pp, rq->srvhdrs); |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | } |
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 | |
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 | * http_status_message from Open Webserver (frame/http.cpp) |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | * TODO: replace, use sstr_t |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | NSAPI_PUBLIC const char * protocol_status_message (int code) |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
65 | WS_ASSERT(code > 0); |
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
82
diff
changeset
|
66 | |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | const char *r; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | switch (code) |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | { |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | case PROTOCOL_CONTINUE : // 100 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | r = "Continue"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | case PROTOCOL_SWITCHING: //101 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | r = "Switching Protocols"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | case PROTOCOL_OK: // 200 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | r = "OK"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | case PROTOCOL_CREATED: // 201 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | r = "Created"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | case PROTOCOL_ACCEPTED: // 202 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | r = "Accepted"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | case PROTOCOL_NONAUTHORITATIVE: // 203 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | r = "Non-Authoritative Information"; |
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_NO_CONTENT: //204 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | /* 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
|
91 | The spec maps this to No Content. |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | Hence cahnging this to No Content |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | r = "No Content"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | case PROTOCOL_RESET_CONTENT: // 205 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | r = "Reset Content"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | case PROTOCOL_PARTIAL_CONTENT: // 206 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | r = "Partial Content"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | case PROTOCOL_MULTI_STATUS: // 207 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | r = "Multi Status"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | case PROTOCOL_MULTIPLE_CHOICES: // 300 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | r = "Multiple Choices"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | case PROTOCOL_MOVED_PERMANENTLY: // 301 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | r = "Moved Permanently"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | case PROTOCOL_REDIRECT: // 302 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | r = "Moved Temporarily"; /* The spec actually says "Found" */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | case PROTOCOL_SEE_OTHER: // 303 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | r = "See Other"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | case PROTOCOL_NOT_MODIFIED: // 304 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | r = "Use local copy"; /* The spec actually says "Not Modified" */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | case PROTOCOL_USE_PROXY: // 305 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | r = "Use Proxy"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | case PROTOCOL_TEMPORARY_REDIRECT: // 307 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | r = "Temporary Redirect"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | case PROTOCOL_BAD_REQUEST: // 400 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | r = "Bad request"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | case PROTOCOL_UNAUTHORIZED: // 401 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | r = "Unauthorized"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | case PROTOCOL_PAYMENT_REQUIRED: // 402 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | r = "Payment Required"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | case PROTOCOL_FORBIDDEN: // 403 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | r = "Forbidden"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | case PROTOCOL_NOT_FOUND: // 404 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | r = "Not found"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
140 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | case PROTOCOL_METHOD_NOT_ALLOWED: // 405 /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | r = "Method Not Allowed"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | case PROTOCOL_NOT_ACCEPTABLE: // 406 /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | r = "Not Acceptable"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | case PROTOCOL_PROXY_UNAUTHORIZED: // 407 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | r = "Proxy Authentication Required"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | case PROTOCOL_REQUEST_TIMEOUT: // 408 /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 | r = "Request Timeout"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | case PROTOCOL_CONFLICT: // 409 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | r = "Conflict"; /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | case PROTOCOL_GONE: // 410 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
157 | r = "Gone"; /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | case PROTOCOL_LENGTH_REQUIRED: // 411 /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | r = "Length Required"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | case PROTOCOL_PRECONDITION_FAIL: // 412 /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | r = "Precondition Failed"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | case PROTOCOL_ENTITY_TOO_LARGE: // 413 /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | r = "Request Entity Too Large"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | case PROTOCOL_URI_TOO_LARGE: // 414 /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | r = "Request-URI Too Large"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
170 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
171 | case PROTOCOL_UNSUPPORTED_MEDIA_TYPE: // 415 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
172 | r = "Unsupported Media Type"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
173 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
174 | case PROTOCOL_REQUESTED_RANGE_NOT_SATISFIABLE: // 416 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | r = "Requested range not satisfiable"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
177 | case PROTOCOL_EXPECTATION_FAILED: // 417 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
178 | r = "Expectation Failed"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
180 | case PROTOCOL_LOCKED: // 423 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
181 | r = "Locked"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
182 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
183 | case PROTOCOL_FAILED_DEPENDENCY: // 424 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
184 | r = "Failed Dependency"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
186 | case PROTOCOL_SERVER_ERROR: // 500 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
187 | r = "Server Error"; /* The spec actually says "Internal Server Error" */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
189 | case PROTOCOL_NOT_IMPLEMENTED: // 501 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
190 | r = "Not Implemented"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
191 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
192 | case PROTOCOL_BAD_GATEWAY: // 502 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
193 | r = "Bad Gateway"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
194 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
195 | case PROTOCOL_SERVICE_UNAVAILABLE: // 503 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
196 | r = "Service Unavailable"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
197 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
198 | case PROTOCOL_GATEWAY_TIMEOUT: // 504 /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | r = "Gateway Timeout"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
201 | case PROTOCOL_VERSION_NOT_SUPPORTED: // 505 /* HTTP/1.1 */ |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
202 | r = "HTTP Version Not Supported"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | case PROTOCOL_INSUFFICIENT_STORAGE: // 507 |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
205 | r = "Insufficient Storage"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
206 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
207 | default: |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
208 | switch (code / 100) |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
209 | { |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
210 | case 1: |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
211 | r = "Information"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
212 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
213 | case 2: |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | r = "Success"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
215 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
216 | case 3: |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
217 | r = "Redirect"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 | case 4: |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
220 | r = "Client error"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
221 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
222 | case 5: |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
223 | r = "Server error"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
224 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
225 | default: |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
226 | r = "Unknown reason"; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
227 | break; |
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 | break; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
230 | } |
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 | return r; |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
233 | } |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
234 | |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
235 | |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
236 | void add_http_status_line(sbuf_t *out, pool_handle_t *pool, Request *rq) { |
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
237 | sbuf_write(out, "HTTP/1.1 ", 9); |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
238 | |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
239 | char *status_code_str = pool_malloc(pool, 8); |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
240 | int sc_len = snprintf(status_code_str, 8, "%d ", rq->status_num); |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
241 | sbuf_write(out, status_code_str, sc_len); |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
242 | |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
243 | char *scmsg = pblock_findkeyval(pb_key_status, rq->srvhdrs); |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
244 | if(scmsg == NULL) { |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
245 | scmsg = "OK"; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
246 | } |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
247 | sbuf_write(out, scmsg, strlen(scmsg)); |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
248 | |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
249 | sbuf_write(out, "\r\n", 2); |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
250 | } |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
251 | |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
252 | void add_http_response_header(sbuf_t *out, Request *rq) { |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
253 | pblock *h = rq->srvhdrs; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
254 | pb_entry *p; |
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 | 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
|
257 | p = h->ht[i]; |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
258 | while(p != NULL) { |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
259 | /* from http.cpp */ |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
260 | 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
|
261 | 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
|
262 | /* Skip internal Status:, Server:, and Date: information */ |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
263 | p = p->next; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
264 | continue; |
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 | /* end http.cpp */ |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
267 | |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
268 | char *name = p->param->name; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
269 | char *value = p->param->value; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
270 | |
77 | 271 | // make first char of name uppercase |
272 | size_t name_len = strlen(name); | |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
273 | if(name[0] > 90) { |
77 | 274 | /* |
275 | * make first char uppercase and write the remaining chars | |
276 | * unmodified to the buffer | |
277 | */ | |
278 | sbuf_put(out, name[0]-32); | |
279 | if(name_len > 1) { | |
280 | sbuf_write(out, name+1, name_len-1); | |
281 | } | |
282 | } else { | |
283 | // first char is already uppercase so just write the name | |
284 | sbuf_write(out, name, name_len); | |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
285 | } |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
286 | |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
287 | sbuf_write(out, ": ", 2); |
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
288 | sbuf_write(out, value, strlen(value)); |
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
289 | sbuf_write(out, "\r\n", 2); |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
290 | |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
291 | p = p->next; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
292 | } |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
293 | } |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
294 | } |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
295 | |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
296 | int http_start_response(Session *sn, Request *rq) { |
108 | 297 | Connection *conn = ((NSAPISession*)sn)->connection; |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
298 | |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
299 | if(rq->status_num == -1) { |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
300 | protocol_status(sn, rq, 200, "OK"); |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
301 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
302 | |
65
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
303 | // set socket blocking |
67
50505dc3f8a6
dynamic thread pool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
304 | //int flags; |
50505dc3f8a6
dynamic thread pool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
305 | //flags = fcntl(fd, F_GETFL, 0); |
50505dc3f8a6
dynamic thread pool
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
306 | //fcntl(fd, F_SETFL, flags ^ O_NONBLOCK); |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
307 | |
65
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
308 | // output buffer |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
309 | sbuf_t *out = sbuf_new(512); |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
310 | |
65
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
311 | // add the http status line to the output buffer |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
312 | add_http_status_line(out, sn->pool, rq); |
65
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
313 | |
103
d3b514e2ddbd
added date header to response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
314 | // add date header |
d3b514e2ddbd
added date header to response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
315 | struct tm mtms; |
d3b514e2ddbd
added date header to response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
316 | struct tm *mtm = system_gmtime(&rq->req_start, &mtms); |
d3b514e2ddbd
added date header to response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
317 | char date[HTTP_DATE_LEN + 1]; |
d3b514e2ddbd
added date header to response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
318 | strftime(date, HTTP_DATE_LEN, HTTP_DATE_FMT, mtm); |
d3b514e2ddbd
added date header to response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
319 | sbuf_write(out, "Date: ", 6); |
d3b514e2ddbd
added date header to response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
320 | sbuf_write(out, date, strlen(date)); |
d3b514e2ddbd
added date header to response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
321 | sbuf_write(out, "\r\n", 2); |
d3b514e2ddbd
added date header to response
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
322 | |
104
a8acbb12f27c
implemented range requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
103
diff
changeset
|
323 | // add server header |
a8acbb12f27c
implemented range requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
103
diff
changeset
|
324 | sbuf_write(out, "Server: webserver\r\n", 19); |
a8acbb12f27c
implemented range requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
103
diff
changeset
|
325 | |
65
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
326 | // check content length ans transfer encoding |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
327 | char *ctlen = pblock_findkeyval(pb_key_content_length, rq->srvhdrs); |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
328 | char *enc = pblock_findkeyval(pb_key_transfer_encoding, rq->srvhdrs); |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
329 | if(ctlen && enc) { |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
330 | pblock_removekey(pb_key_transfer_encoding, rq->srvhdrs); |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
331 | } |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
332 | if(!ctlen) { |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
333 | // set transfer-encoding header |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
334 | if(!enc) { |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
335 | pblock_kvinsert( |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
336 | pb_key_transfer_encoding, |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
337 | "chunked", |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
338 | 7, |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
339 | rq->srvhdrs); |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
340 | } else if(strcmp(enc, "chunked")) { |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
341 | pblock_removekey(pb_key_transfer_encoding, rq->srvhdrs); |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
342 | pblock_kvinsert( |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
343 | pb_key_transfer_encoding, |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
344 | "chunked", |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
345 | 7, |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
346 | rq->srvhdrs); |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
347 | } |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
348 | |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
349 | // set stream property |
251
f727a21497bb
add basic PUT implementation and tests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
350 | HttpStream *stream = (HttpStream*)sn->csd; // TODO: make this typesafe |
66
74babc0082b7
added authentication cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
65
diff
changeset
|
351 | stream->chunked_enc = 1; |
80
0de4a90979e1
fixed chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
352 | rq->rq_attr.chunked = 1; |
65
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
353 | } |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
354 | |
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
355 | // add header from rq->srvhdrs |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
356 | add_http_response_header(out, rq); |
48
37a512d7b8f6
fixed some memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
357 | |
65
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
358 | // add connection header |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
359 | if(rq->rq_attr.keep_alive) { |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
360 | sbuf_write(out, "Connection: keep-alive\r\n", 24); |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
361 | pblock_kvinsert(pb_key_connection, "keep-alive", 10, rq->srvhdrs); |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
362 | } else { |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
363 | sbuf_write(out, "Connection: close\r\n", 19); |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
364 | pblock_kvinsert(pb_key_connection, "close", 5, rq->srvhdrs); |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
365 | } |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
87
diff
changeset
|
366 | |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
367 | |
65
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
368 | // response header end |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
369 | sbuf_write(out, "\r\n", 2); |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
370 | |
65
14722c5f8856
added chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
48
diff
changeset
|
371 | // flush buffer to the socket |
108 | 372 | conn->write(conn, out->ptr, out->length); |
11
24d804a2799f
Fixed response header bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
9
diff
changeset
|
373 | sbuf_free(out); |
141 | 374 | |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
375 | rq->senthdrs = 1; |
38
d07810b02147
added ldap authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
376 | |
d07810b02147
added ldap authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
377 | return 0; |
4
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
378 | } |
998844b5ed25
Added some protocol functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
379 | |
235
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
380 | int http_send_continue(Session *sn) { |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
381 | NSAPISession *s = (NSAPISession*)sn; |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
382 | sstr_t msg = S("HTTP/1.1 100 Continue\r\n\r\n"); |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
383 | int w = s->connection->write(s->connection, msg.ptr, msg.length); |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
384 | if(w != msg.length) { |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
385 | return 1; |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
386 | } |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
387 | return 0; |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
388 | } |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
389 | |
9
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
390 | int request_header(char *name, char **value, Session *sn, Request *rq) { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
391 | const pb_key *key = pblock_key(name); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
392 | pb_param *pp = pblock_findkey(key, rq->headers); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
393 | if(pp != NULL) { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
394 | *value = pp->value; |
9
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
395 | return REQ_PROCEED; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
396 | } else { |
38
d07810b02147
added ldap authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
397 | //return REQ_ABORTED; |
d07810b02147
added ldap authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
398 | *value = NULL; |
d07810b02147
added ldap authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
399 | return REQ_NOACTION; |
9
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
400 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
401 | } |
82
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
402 | |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
403 | char *http_uri2url(const char *prefix, const char *suffix) { |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
404 | // TODO: implement |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
405 | return NULL; |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
406 | } |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
407 | |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
408 | char *http_uri2url_dynamic(const char *prefix, const char *suffix, |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
409 | Session *sn, Request *rq) |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
410 | { |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
411 | // TODO: implement |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
412 | return NULL; |
740cfd9dd443
added some nsapi stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
413 | } |
121
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
414 | |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
415 | void http_get_scheme_host_port( |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
416 | Session *sn, |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
417 | Request *rq, |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
418 | char **scheme, |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
419 | char **host, |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
420 | uint16_t *port) |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
421 | { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
422 | Connection *con = ((NSAPISession*)sn)->connection; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
423 | |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
424 | if(con->ssl) { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
425 | *scheme = HTTPS_SCHEME; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
426 | } else { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
427 | *scheme = HTTP_SCHEME; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
428 | } |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
429 | |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
430 | NSAPIRequest *request = (NSAPIRequest*)rq; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
431 | |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
432 | if(request->host) { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
433 | *host = request->host; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
434 | } else { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
435 | *host = "localhost"; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
436 | } |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
437 | |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
438 | *port = request->port; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
439 | |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
440 | } |