}
#if NET_1_1
+ bool unsafe_auth_blah;
[MonoTODO]
public bool UnsafeAuthenticatedConnectionSharing
{
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return unsafe_auth_blah; }
+ set { unsafe_auth_blah = value; }
}
#endif
throw new InvalidOperationException ("rangeSpecifier");
webHeaders.RemoveAndAdd ("Range", value + from + "-" + to);
}
-
+#if !NET_2_0
public override int GetHashCode ()
{
return base.GetHashCode ();
}
+#endif
void CommonChecks (bool putpost)
{
return EndGetRequestStream (asyncResult);
}
-
+
+ void CheckIfForceWrite ()
+ {
+ if (writeStream == null || contentLength < 0 || !InternalAllowBuffering)
+ return;
+
+ // This will write the POST/PUT if the write stream already has the expected
+ // amount of bytes in it (ContentLength) (bug #77753).
+ if (writeStream.WriteBufferLength == contentLength)
+ writeStream.WriteRequest ();
+ }
+
public override IAsyncResult BeginGetResponse (AsyncCallback callback, object state)
{
bool send = (method == "PUT" || method == "POST");
"method while a previous call is still in progress.");
}
+ CheckIfForceWrite ();
asyncRead = new WebAsyncResult (this, callback, state);
initialMethod = method;
if (haveResponse) {
{
bool continue100 = false;
if (contentLength != -1) {
- continue100 = true;
+ if (contentLength > 0)
+ continue100 = true;
webHeaders.SetInternal ("Content-Length", contentLength.ToString ());
webHeaders.RemoveInternal ("Transfer-Encoding");
} else if (sendChunked) {
contentLength = bodyBufferLength;
writeStream.SendChunked = false;
}
-
+
SendRequestHeaders ();
haveRequest = true;
void CheckSendError (WebConnectionData data)
{
// Got here, but no one called GetResponse
- if (data.StatusCode < 400)
+ int status = data.StatusCode;
+ if (status < 400 || status == 401 || status == 407)
return;
if (writeStream != null && asyncRead == null && !writeStream.CompleteRequestWritten) {
WebExceptionStatus protoError = WebExceptionStatus.ProtocolError;
HttpStatusCode code = 0;
if (throwMe == null && webResponse != null) {
- code = webResponse.StatusCode;
+ code = webResponse.StatusCode;
if (!authCompleted && ((code == HttpStatusCode.Unauthorized && credentials != null) ||
- code == HttpStatusCode.ProxyAuthenticationRequired)) {
+ (ProxyQuery && code == HttpStatusCode.ProxyAuthenticationRequired))) {
if (!usedPreAuth && CheckAuthorization (webResponse, code)) {
// Keep the written body, so it can be rewritten in the retry
if (InternalAllowBuffering) {
if (throwMe == null) {
bool b = false;
int c = (int) code;
- if (allowAutoRedirect && c >= 300)
+ if (allowAutoRedirect && c >= 300) {
+ if (InternalAllowBuffering && writeStream.WriteBufferLength > 0) {
+ bodyBuffer = writeStream.WriteBuffer;
+ bodyBufferLength = writeStream.WriteBufferLength;
+ }
b = Redirect (result, code);
+ }
if (resp != null && c >= 300 && c != 304)
resp.ReadAll ();