summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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]));