Added error handling to skipHeaders to prevent usable of httpReturnCode on invalid returns - #15
Merged
Conversation
…de on invalid returns Added error handling to skipHeaders to prevent usable of httpReturnCode on invalid returns
Simplified check because it is only relevant if the status code could be read - all other error cases are handled by later code too
When the server closed the connection and all data are read, the socket is in „CLOSE-WAIT“ status … but in this combination „connected“ returns false, even if the socket is not really closed on the client. This is not a real problem because normally „CLOSE_WAIT“ sockets are reused for new connections, but it may end up in problems any may cause problems. (I try to tackle down the effect that sometimes no more connections are possible …) The solution is to call „stop“ in any case when the Stream should be closed because with this the connection is closed correctly in any case. A double call is handed by „stop“ automatically so don’t worry about this.
- Added some checks that stream variable is not NULL before using it (just to make sure) - To avoid header-read errors that happened sometimes implement a check for available data with a maximum timeout of 1000ms (configurable via defines in header file). With my default settings we wait 20 ms and then check again if at least 17 characters are available to read (which should be a normal HTTP-header first line). This is done at max 50 times before the read is tried
Contributor
Author
|
I added solution for issue #3 too ... |
interactive-matter
added a commit
that referenced
this pull request
Nov 9, 2015
Added error handling to skipHeaders to prevent usable of httpReturnCode on invalid returns
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added error handling to skipHeaders to prevent usable of httpReturnCode
on invalid returns, May fix Issue #3. In any case „lastReturnCode“ will be re-set to NULL for any request, so if not successful to skip headers „NULL“ is the „last“ return Code
Additionally changed some code in "closeStream" to make sure that connection is always closed correctly by calling "stop" and not leaving "CLOSE_WAIT" sockets