Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
limit the amount of redirects to a fixed number and also don't create…
… a new request object since it's already setup for us
- Loading branch information
Showing
2 changed files
with
14 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,13 +159,16 @@ def connection(connection, didReceiveData:received_data) | |
def connection(connection, willSendRequest:request, redirectResponse:redirect_response) | ||
@redirection ||= 0 | ||
@redirection += 1 | ||
log "##{@redirection} HTTP redirection: #{request} - #{self.description}" | ||
new_request = request.mutableCopy | ||
# new_request.setValue(@credentials.inspect, forHTTPHeaderField:'Authorization') # disabled while we figure this one out | ||
new_request.setAllHTTPHeaderFields(@headers) if @headers | ||
@connection.cancel | ||
@connection = create_connection(new_request, self) | ||
new_request | ||
log "##{@redirection} HTTP redirection: #{request.inspect} - #{self.description}" | ||
if @redirection >= 30 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nov
Contributor
|
||
log "Too many redirections" | ||
@response.error_message = "Too many redirections" | ||
@request.done_loading! | ||
call_delegator_with_response | ||
nil | ||
else | ||
request | ||
end | ||
end | ||
|
||
def connection(connection, didFailWithError: error) | ||
|
I feel 30 is too large for iOS device, especially in 3G network.
Maybe 5 or 6 is enough?