X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_info.c;h=876c7203533bd7b7879b99a7957658adcdcd1a91;hp=2c0f11474b810886962de0861ac6ea25da8e9c5c;hb=db0ebb809983eb3dbda84dee61dfceb08feb20c3;hpb=455b900ef81b046e1102f267e711338382019253 diff --git a/php_http_info.c b/php_http_info.c index 2c0f114..876c720 100644 --- a/php_http_info.c +++ b/php_http_info.c @@ -116,11 +116,20 @@ php_http_info_t *php_http_info_parse(php_http_info_t *info, const char *pre_head info->type = PHP_HTTP_REQUEST; if (url && http > url) { - PHP_HTTP_INFO(info).request.method = estrndup(pre_header, url - pre_header); + size_t url_len = url - pre_header; + + PHP_HTTP_INFO(info).request.method = estrndup(pre_header, url_len); + while (' ' == *url) ++url; while (' ' == *(http-1)) --http; + if (http > url) { - PHP_HTTP_INFO(info).request.url = php_http_url_parse(url, http - url, ~0 TSRMLS_CC); + /* CONNECT presents an authority only */ + if (strcasecmp(PHP_HTTP_INFO(info).request.method, "CONNECT")) { + PHP_HTTP_INFO(info).request.url = php_http_url_parse(url, http - url, ~0 TSRMLS_CC); + } else { + PHP_HTTP_INFO(info).request.url = php_http_url_parse_authority(url, http - url, ~0 TSRMLS_CC); + } } else { PTR_SET(PHP_HTTP_INFO(info).request.method, NULL); return NULL;