My previous changes modified the way how we're handing the request body when
resending a request due to a 30x redirection.
Authentication is a "special" form of redirection because we sometimes need
to resend a request with additional authentication headers. Unfortunately,
I forgot this, causing a regression which is now fixed.
This has been reported as bugs #19119 and #19068.
* Merged WebConnection.EndWrite() and EndWrite2().
* WebConnectionStream.BeginWrite(): Use the same async-write
callback for both chunked and non-chunked; remove the single-use
small WriteRequestAsync() and inline it here to make the code
more readable.
* WebConnectionStream.WriteRequestAsyncCB(): Now called for all
async writes, call WebConnection.EndWrite() here.
The code is now more readable and easier to understand. This is
the first part of a series of cleanups, which should eventually
lead towards full async and 100-continue.
Revert "Revert "Merge pull request #829 from symform/httpwebreq-async-ssl""
This reverts commit 56d9a057eb, which was a
revert of 35899c07ff, thus putting 35889 back.
EndGetRequestStream with TransportContext parameter was introduced in .NET 3.5. Also added "using" statement for System.Net (namespace for TransportContext).
I am not sure if a "do-nothing" implementation like this is acceptable in the Mono code base, but it does solve the problem described in https://bugzilla.xamarin.com/show_bug.cgi?id=12875 (successfully executing simple requests using the Google API .NET client library).
More details:
* HttpWebRequest now writes the HTTP request headers asynchronously. This will avoid blocking a thread pool thread until the headers are written.
* SslClientStream was doing the TLS negotiations in a blocking manner. Converted the negotiation method to an async state machine where all operations are done asynchronously.
* The test case identified in #15451 now completes quickly with less than 15 threads created, vs. 100s of threads used before this fix.
Future work if needed:
* I did not convert SslServerStream but the same pattern could be used here.
* SendAlert is still blocking. I thought it was not worth converting it to non-blocking.
HttpWebRequest is a very tricky piece of code when it comes to its socket, this patch is more like a hack to get something working out of it but it's definitely not the best option.
This reverts commit b190db44cb.
The reason is:
"The HttpWebRequests tests are not enough"
"A quick review of the code shows that the code is taking a lock, while
calling a function that retries connections (which in turn takes another
important lock --for the socket--) which might casue a stack overflow
if someone calls SetWriteStream"
"This also will make the opereation sync when calling Begin/End"
"Finally, this is a patch that improves the use of the threadpool, but
the threadpool still will end up exhausted"
Probably best to just increase the number of threads?
The code path for synchronous requests was the same as the one for
asynchronous ones: the threadpool. It's actually not needed in this
case because the thread is going to wait anyway, so there's no need
to use the threadpool.
This helps in scenarios in which SOA is heavily used:
- The process is hosted under xsp/mono-fastcgi/... which use the threadpool
too.
- If the requests generate other requests to other REST services, the
usage of the threadpool in these cases may interfere with the usage of
the threadpool by xsp/mono-fastcgi/...
- The thread that is serving a request shouldn't request another thread
for a blocking operation, preventing the use of that thread by other
possible incoming requests.
This commit is contributed under the terms of MIT/X11 licence.
(It doesn't cause any breakage in the System test suite.)
Add internal WebHeaderCollection.GetValues_internal() which lets
you disable splitting the results on commas.
We may get something like
Proxy-Authenticate: Digest realm="MyRealm", nonce="le1+UCAk1gLAdQAA",
qop="auth", stale=false, NTLM
from the server, which needs to be split into two headers.
Previously, cookies from the WebHeaderCollection and CookieContainer were sent. This also fixes a bug with ServicePoint sending duplicate cookies when SendRequestHeaders is called more than once:
* WebConnection.InitConnection
* HttpWebRequest.SetWriteStream
* HttpWebRequest. SendRequestHeaders
* WebConnectionStream.WriteRequest
* HttpWebRequest.SendRequestHeaders
Replacing the cookie header value in the WebHeaderCollection with the cookies stored in the CookieContainer also matches the behavior of Microsoft's .NET implementation.