summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2017-05-18 11:05:21 +0200
committerChristian Schneider2017-05-18 11:05:21 +0200
commitfd44cd53734a7b1a18343e11682a548f63ebbc50 (patch)
tree793878dfdd06c0fa9184c68141aad379d3aa186b
parentdda47207fcb7a2101048deaae3508c09f8b013e8 (diff)
downloaditools-fd44cd53734a7b1a18343e11682a548f63ebbc50.tar.gz
itools-fd44cd53734a7b1a18343e11682a548f63ebbc50.tar.bz2
itools-fd44cd53734a7b1a18343e11682a548f63ebbc50.zip
Do not follow redirect for HTTP 201 Created because that can send the Location of the new resource
-rw-r--r--it_url.class3
1 files changed, 2 insertions, 1 deletions
diff --git a/it_url.class b/it_url.class
index 4f184ac..2b1ee18 100644
--- a/it_url.class
+++ b/it_url.class
@@ -129,7 +129,8 @@ function get($p=null, $timeout=5)
else
$result = $url->request_curl($p);
- if ($url->headers['Location'] && preg_match('#^(https?://[^/]*)?(/)?(.*)$#i', $url->headers['Location'], $parts) && ($parts[1] != $url->url)) # Handle redirects (supports relative and global)
+ # Handle redirects (supports relative and global) but not for HTTP 201 Created because that can send the Location of the new resource
+ if ($url->headers['Location'] && $url->result != 201 && preg_match('#^(https?://[^/]*)?(/)?(.*)$#i', $url->headers['Location'], $parts) && ($parts[1] != $url->url))
{
unset($p['url'], $p['headers']['Host']);
$url->it_url($parts[1] ? $parts[1].$parts[2].$parts[3] : $url->protocol.'://'.$url->realhostname.($parts[2] ? $parts[2].$parts[3] : '/'.dirname($url->path).'/'.$parts[3]));