forked from organicmaps/organicmaps
[downloader] We DO NOT support redirects on any platform
This commit is contained in:
parent
d4f7329a83
commit
97ad28ad64
2 changed files with 21 additions and 3 deletions
|
@ -98,6 +98,24 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
/// We cancel and don't support any redirects to avoid data corruption
|
||||
-(NSURLRequest *)connection:(NSURLConnection *)connection
|
||||
willSendRequest:(NSURLRequest *)request
|
||||
redirectResponse:(NSURLResponse *)redirectResponse
|
||||
{
|
||||
if (!redirectResponse)
|
||||
{
|
||||
// Special case, system just normalizes request, it's not a real redirect
|
||||
return request;
|
||||
}
|
||||
// In all other cases we are cancelling redirects
|
||||
LOG(LWARNING, ("Canceling because of redirect from", [[[redirectResponse URL] absoluteString] UTF8String],
|
||||
"to", [[[request URL] absoluteString] UTF8String]));
|
||||
[connection cancel];
|
||||
m_callback->OnFinish(-3, m_begRange, m_endRange);
|
||||
return nil;
|
||||
}
|
||||
|
||||
/// @return -1 if can't decode
|
||||
+ (int64_t) getContentRange:(NSDictionary *)httpHeader
|
||||
{
|
||||
|
|
|
@ -142,11 +142,11 @@ UNIT_TEST(DownloaderSimpleGet)
|
|||
|
||||
observer.Reset();
|
||||
{
|
||||
// permanent redirect success case
|
||||
// We DO NOT SUPPORT redirects to avoid data corruption when downloading mwm files
|
||||
scoped_ptr<HttpRequest> request(HttpRequest::Get(TEST_URL_PERMANENT, onFinish, onProgress));
|
||||
QCoreApplication::exec();
|
||||
observer.TestOk();
|
||||
TEST_EQUAL(request->Data(), "Test1", ());
|
||||
observer.TestFailed();
|
||||
TEST_EQUAL(request->Data().size(), 0, (request->Data()));
|
||||
}
|
||||
|
||||
observer.Reset();
|
||||
|
|
Loading…
Add table
Reference in a new issue