diff options
| author | 2018-09-04 17:33:10 +0200 | |
|---|---|---|
| committer | 2018-09-04 17:33:10 +0200 | |
| commit | c02e605ebfbf1c6c67506e10ef26a6a6f383614f (patch) | |
| tree | 845d4f0368ce6999e8cc4c1511ae326692e9aedd /src/kvilib/net/KviHttpRequest.cpp | |
| parent | List object updates; fix #2384 (diff) | |
| download | KVIrc-c02e605ebfbf1c6c67506e10ef26a6a6f383614f.tar.gz KVIrc-c02e605ebfbf1c6c67506e10ef26a6a6f383614f.tar.bz2 KVIrc-c02e605ebfbf1c6c67506e10ef26a6a6f383614f.zip | |
KviHttp: support relative redirects; fix #2398 (#2399)
* mac: fix plugin installation
* c++11: fix some compiler warnings
* KviHttp: support relative redirects; fix #2398
KviUrl: permit modification of the url
KviHttpRequest: check for relative redirects and change the url's path
Diffstat (limited to 'src/kvilib/net/KviHttpRequest.cpp')
| -rw-r--r-- | src/kvilib/net/KviHttpRequest.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/kvilib/net/KviHttpRequest.cpp b/src/kvilib/net/KviHttpRequest.cpp index ae1804921..af2ebf4f3 100644 --- a/src/kvilib/net/KviHttpRequest.cpp +++ b/src/kvilib/net/KviHttpRequest.cpp @@ -717,9 +717,10 @@ bool KviHttpRequest::processHeader(KviCString & szHeader) return false; } - KviCString * location = hdr.find("Location"); + KviCString * headerLocation = hdr.find("Location"); + QString location(headerLocation->ptr()); - if(!location) + if(location.isEmpty()) { resetInternalStatus(); m_szLastError = __tr2qs("Bad redirect"); @@ -727,7 +728,17 @@ bool KviHttpRequest::processHeader(KviCString & szHeader) return false; } - KviUrl url(location->ptr()); + KviUrl url; + + if(location.startsWith('/')) + { + // relative redirect, use the old url and only update the path + url = m_connectionUrl; + url.setPath(location); + } else { + // absolute redirect + url.setUrl(location); + } if( (url.url() == m_connectionUrl.url()) || (url.url() == m_url.url())) |
