Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added error handling to skipHeaders to prevent usable of httpReturnCode on invalid returns #15

Merged
merged 4 commits into from
Nov 9, 2015

Conversation

Apollon77
Copy link
Contributor

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

Apollon77 and others added 4 commits September 14, 2015 11:52
…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
@Apollon77
Copy link
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
@interactive-matter interactive-matter merged commit 9bd0522 into interactive-matter:master Nov 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants