projects
/
m6w6
/
ext-http
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
455b900
)
use url authority parser for CONNECT messages
author
Michael Wallner
<mike@php.net>
Thu, 5 Feb 2015 10:17:16 +0000
(11:17 +0100)
committer
Michael Wallner
<mike@php.net>
Thu, 5 Feb 2015 10:17:16 +0000
(11:17 +0100)
php_http_info.c
patch
|
blob
|
history
php_http_info.h
patch
|
blob
|
history
diff --git
a/php_http_info.c
b/php_http_info.c
index 2c0f11474b810886962de0861ac6ea25da8e9c5c..876c7203533bd7b7879b99a7957658adcdcd1a91 100644
(file)
--- 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) {
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;
while (' ' == *url) ++url;
while (' ' == *(http-1)) --http;
+
if (http > url) {
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;
} else {
PTR_SET(PHP_HTTP_INFO(info).request.method, NULL);
return NULL;
diff --git
a/php_http_info.h
b/php_http_info.h
index d31b505d8d3e378b99628acbf4b906e2cb179121..4f02908446b6c0c430eb6bb39269f45967500b00 100644
(file)
--- a/
php_http_info.h
+++ b/
php_http_info.h
@@
-18,7
+18,9
@@
#define PHP_HTTP_INFO_REQUEST_FMT_ARGS(_http_ptr, tmp, eol) "%s %s HTTP/%u.%u" eol, \
(_http_ptr)->info.request.method?(_http_ptr)->info.request.method:"UNKNOWN", \
#define PHP_HTTP_INFO_REQUEST_FMT_ARGS(_http_ptr, tmp, eol) "%s %s HTTP/%u.%u" eol, \
(_http_ptr)->info.request.method?(_http_ptr)->info.request.method:"UNKNOWN", \
- (_http_ptr)->info.request.url?php_http_url_to_string((_http_ptr)->info.request.url, &(tmp), NULL, 0):"/", \
+ (_http_ptr)->info.request.method&&!strcasecmp((_http_ptr)->info.request.method,"CONNECT")?( \
+ (_http_ptr)->info.request.url?php_http_url_authority_to_string((_http_ptr)->info.request.url, &(tmp), NULL):"0"):( \
+ (_http_ptr)->info.request.url?php_http_url_to_string((_http_ptr)->info.request.url, &(tmp), NULL, 0):"/"), \
(_http_ptr)->version.major||(_http_ptr)->version.major?(_http_ptr)->version.major:1, \
(_http_ptr)->version.major||(_http_ptr)->version.minor?(_http_ptr)->version.minor:1
(_http_ptr)->version.major||(_http_ptr)->version.major?(_http_ptr)->version.major:1, \
(_http_ptr)->version.major||(_http_ptr)->version.minor?(_http_ptr)->version.minor:1