182 if(!sstrcmp(request->httpv, S("HTTP/1.1"))) { |
182 if(!sstrcmp(request->httpv, S("HTTP/1.1"))) { |
183 rq->rq.protv_num = PROTOCOL_VERSION_HTTP11; |
183 rq->rq.protv_num = PROTOCOL_VERSION_HTTP11; |
184 } else if(!sstrcmp(request->httpv, S("HTTP/1.0"))) { |
184 } else if(!sstrcmp(request->httpv, S("HTTP/1.0"))) { |
185 rq->rq.protv_num = PROTOCOL_VERSION_HTTP10; |
185 rq->rq.protv_num = PROTOCOL_VERSION_HTTP10; |
186 } else { |
186 } else { |
187 // TODO: invalid protocol version - abort |
187 // invalid protocol version - abort |
|
188 log_ereport( |
|
189 LOG_FAILURE, |
|
190 "invalid protocol version: %.*s", |
|
191 (int)request->httpv.length, |
|
192 request->httpv.ptr); |
|
193 pool_destroy(pool); |
|
194 return 1; |
188 } |
195 } |
189 |
196 |
190 /* |
197 /* |
191 * get absolute path and query of the request uri |
198 * get absolute path and query of the request uri |
192 */ |
199 */ |
238 absPath.ptr, |
245 absPath.ptr, |
239 absPath.length, |
246 absPath.length, |
240 rq->rq.reqpb); |
247 rq->rq.reqpb); |
241 } else { |
248 } else { |
242 // TODO: log error |
249 // TODO: log error |
243 printf("unescape failed\n"); |
250 log_ereport(LOG_WARN, "uri unescape failed"); |
244 pblock_kvinsert(pb_key_uri, "/", 1, rq->rq.reqpb); |
251 pblock_kvinsert(pb_key_uri, "/", 1, rq->rq.reqpb); |
245 } |
252 } |
246 |
253 |
247 // pass http header to the NSAPI request structure |
254 // pass http header to the NSAPI request structure |
248 int hlen = request->headers->len; |
255 int hlen = request->headers->len; |
603 |
610 |
604 // if no function has set the ppath var, translate it to docroot |
611 // if no function has set the ppath var, translate it to docroot |
605 if(ret == REQ_NOACTION && ppath == NULL) { |
612 if(ret == REQ_NOACTION && ppath == NULL) { |
606 sstr_t docroot = rq->vs->document_root; |
613 sstr_t docroot = rq->vs->document_root; |
607 if(docroot.length < 1) { |
614 if(docroot.length < 1) { |
608 printf("docroot too short\n"); |
615 log_ereport( |
609 return REQ_ABORTED; /* docroot too short */ |
616 LOG_WARN, |
|
617 "VirtualServer(%.*s) docroot too short", |
|
618 (int)rq->vs->name.length, |
|
619 rq->vs->name.ptr); |
|
620 return REQ_ABORTED; // docroot too short |
610 } |
621 } |
611 |
622 |
612 // if there is a trailing '/', remove it |
623 // if there is a trailing '/', remove it |
613 /* |
624 /* |
614 if(docroot.ptr[docroot.length - 1] == '/') { |
625 if(docroot.ptr[docroot.length - 1] == '/') { |