src/server/daemon/httprequest.c

changeset 59
ab25c0a231d0
parent 54
3a1d5a52adfc
child 60
feb2f1e115c6
equal deleted inserted replaced
58:66c22e54aa90 59:ab25c0a231d0
119 pb_key_clf_request, 119 pb_key_clf_request,
120 request->request_line.ptr, 120 request->request_line.ptr,
121 request->request_line.length, 121 request->request_line.length,
122 rq->rq.reqpb); 122 rq->rq.reqpb);
123 123
124 /* Pass method as "method" in reqpb, and also as method_num */ 124 // Pass method as "method" in reqpb, and also as method_num
125 pblock_kvinsert( 125 pblock_kvinsert(
126 pb_key_method, 126 pb_key_method,
127 request->method.ptr, 127 request->method.ptr,
128 request->method.length, 128 request->method.length,
129 rq->rq.reqpb); 129 rq->rq.reqpb);
130 // TODO: method num 130 // TODO: method num
131 //rqRq.rq.method_num = rqHdr->GetMethodNumber(); 131 //rqRq.rq.method_num = rqHdr->GetMethodNumber();
132 //PR_ASSERT(rqRq.rq.method_num != -1 || iStatus); 132 //PR_ASSERT(rqRq.rq.method_num != -1 || iStatus);
133 133
134 /* Pass protocol as "protocol" in reqpb, and also in protv_num */ 134 // Pass protocol as "protocol" in reqpb, and also in protv_num
135 pblock_kvinsert( 135 pblock_kvinsert(
136 pb_key_protocol, 136 pb_key_protocol,
137 request->httpv.ptr, 137 request->httpv.ptr,
138 request->httpv.length, 138 request->httpv.length,
139 rq->rq.reqpb); 139 rq->rq.reqpb);
154 query.length = absPath.length - i - 1; 154 query.length = absPath.length - i - 1;
155 query.ptr = absPath.ptr + i + 1; 155 query.ptr = absPath.ptr + i + 1;
156 } 156 }
157 absPath.length = i; 157 absPath.length = i;
158 158
159 /* Pass any query as 'query' in reqpb */ 159 // Pass any query as 'query' in reqpb
160 pblock_kvinsert( 160 pblock_kvinsert(
161 pb_key_query, 161 pb_key_query,
162 query.ptr, 162 query.ptr,
163 query.length, 163 query.length,
164 rq->rq.reqpb); 164 rq->rq.reqpb);
165 165
166 break; 166 break;
167 } 167 }
168 } 168 }
169 169
170 /* Get abs_path part of request URI, and canonicalize the path */ 170 // Get abs_path part of request URI, and canonicalize the path
171 absPath.ptr = util_canonicalize_uri( 171 absPath.ptr = util_canonicalize_uri(
172 pool, 172 pool,
173 absPath.ptr, 173 absPath.ptr,
174 absPath.length, 174 absPath.length,
175 (int*)&absPath.length); 175 (int*)&absPath.length);
176 176
177 /* Decode the abs_path */ 177 // Decode the abs_path
178 // TODO: decode abs_path (done?) 178 if(util_uri_unescape_strict(absPath.ptr)) {
179 179 // Pass the abs_path as 'uri' in reqpb
180 /* Pass the abs_path as 'uri' in reqpb */ 180 pblock_kvinsert(
181 pblock_kvinsert( 181 pb_key_uri,
182 pb_key_uri, 182 absPath.ptr,
183 absPath.ptr, 183 absPath.length,
184 absPath.length, 184 rq->rq.reqpb);
185 rq->rq.reqpb); 185 } else {
186 // TODO: log error
187 printf("unescape failed\n");
188 pblock_kvinsert(pb_key_uri, "/", 1, rq->rq.reqpb);
189 }
186 190
187 // pass http header to the NSAPI request structure 191 // pass http header to the NSAPI request structure
188 int hlen = request->headers->len; 192 int hlen = request->headers->len;
189 HeaderArray *ha = request->headers; 193 HeaderArray *ha = request->headers;
190 for(int i=0;i<=hlen;i++) { 194 for(int i=0;i<=hlen;i++) {
191 if(i == hlen) { 195 if(i == hlen) {
192 ha = ha->next; 196 ha = ha->next;
193 if(ha == NULL) { 197 if(ha == NULL) {
222 226
223 printf("request body length: %d\n", ctlen); 227 printf("request body length: %d\n", ctlen);
224 228
225 netbuf *nb = request->netbuf; 229 netbuf *nb = request->netbuf;
226 230
227 /* create new netbuf */ 231 // create new netbuf
228 NetIOStream *net_io = (NetIOStream*)net_stream_from_fd( 232 NetIOStream *net_io = (NetIOStream*)net_stream_from_fd(
229 pool, 233 pool,
230 request->connection->fd); 234 request->connection->fd);
231 net_io->max_read = ctlen; 235 net_io->max_read = ctlen;
232 236

mercurial