提交 f647afb0 编写于 作者: M Martin Baulig

[Http]: Correctly handle request bodies when resending with authentication.

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.
上级 0096790a
......@@ -1156,12 +1156,6 @@ namespace System.Net
throw e;
contentLength = -1;
//bodyBufferLength = 0;
//bodyBuffer = null;
if (sendChunked) {
sendChunked = false;
webHeaders.RemoveInternal ("Transfer-Encoding");
}
uriString = webResponse.Headers ["Location"];
if (uriString == null)
......@@ -1191,7 +1185,10 @@ namespace System.Net
} else if (contentLength != -1) {
if (auth_state.NtlmAuthState == NtlmAuthState.Challenge || proxy_auth_state.NtlmAuthState == NtlmAuthState.Challenge) {
// We don't send any body with the NTLM Challenge request.
webHeaders.SetInternal ("Content-Length", "0");
if (haveContentLength || gotRequestStream || contentLength > 0)
webHeaders.SetInternal ("Content-Length", "0");
else
webHeaders.RemoveInternal ("Content-Length");
} else {
if (contentLength > 0)
continue100 = true;
......@@ -1534,6 +1531,11 @@ namespace System.Net
r.SetCompleted (false, webResponse);
r.DoCallback ();
} else {
if (sendChunked) {
sendChunked = false;
webHeaders.RemoveInternal ("Transfer-Encoding");
}
if (webResponse != null) {
if (HandleNtlmAuth (r))
return;
......@@ -1668,11 +1670,7 @@ namespace System.Net
if (!usedPreAuth && CheckAuthorization (webResponse, code)) {
// Keep the written body, so it can be rewritten in the retry
if (InternalAllowBuffering) {
// NTLM: This is to avoid sending data in the 'challenge' request
// We save it in the first request (first 401), don't send anything
// in the challenge request and send it in the response request along
// with the buffers kept form the first request.
if (auth_state.NtlmAuthState == NtlmAuthState.Challenge || proxy_auth_state.NtlmAuthState == NtlmAuthState.Challenge) {
if (writeStream.WriteBufferLength > 0) {
bodyBuffer = writeStream.WriteBuffer;
bodyBufferLength = writeStream.WriteBufferLength;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册