+2008-08-22 Zoltan Varga <vargaz@gmail.com>
+
+ * WebConnectionStream.cs (WriteRequest): For small requests,
+ cluster together the header + body in a single write call, avoids
+ the latency problems observed in an TLS application that makes
+ many web service calls.
+
+2008-08-22 Geoff Norton <gnorton@novell.com>
+
+ * WebConnection.cs: Set NoDelay
+
2008-08-21 Stephane Delcroix <sdelcroix@novell.com>
* OpenReadCompletedEventArgs.cs: new Address property for 2.1
request.InternalContentLength = length;
request.SendRequestHeaders ();
requestWritten = true;
- if (!cnc.Write (headers, 0, headers.Length))
- throw new WebException ("Error writing request.", null, WebExceptionStatus.SendFailure, null);
- headersSent = true;
- if (cnc.Data.StatusCode != 0 && cnc.Data.StatusCode != 100)
- return;
-
- IAsyncResult result = null;
- if (length > 0)
- result = cnc.BeginWrite (bytes, 0, length, null, null);
-
- if (!initRead) {
- initRead = true;
- WebConnection.InitRead (cnc);
- }
+ //
+ // For small requests, make a copy, it will reduce the traffic, for large
+ // requests, the NoDelay bit on the socket should take effect (set in WebConnection).
+ //
+ if (headers.Length + length < 8192){
+ byte[] b = new byte [headers.Length + length];
- if (length > 0)
- complete_request_written = cnc.EndWrite (result);
- else
+ headers.CopyTo (b, 0);
+ bytes.CopyTo (b, headers.Length);
+
+ if (!cnc.Write (b, 0, b.Length))
+ throw new WebException ("Error writing request.", null, WebExceptionStatus.SendFailure, null);
+
+ headersSent = true;
complete_request_written = true;
+
+ if (!initRead) {
+ initRead = true;
+ WebConnection.InitRead (cnc);
+ }
+ } else {
+ if (!cnc.Write (headers, 0, headers.Length))
+ throw new WebException ("Error writing request.", null, WebExceptionStatus.SendFailure, null);
+
+ headersSent = true;
+ if (cnc.Data.StatusCode != 0 && cnc.Data.StatusCode != 100)
+ return;
+
+ IAsyncResult result = null;
+ if (length > 0)
+ result = cnc.BeginWrite (bytes, 0, length, null, null);
+
+ if (!initRead) {
+ initRead = true;
+ WebConnection.InitRead (cnc);
+ }
+
+ if (length > 0)
+ complete_request_written = cnc.EndWrite (result);
+ else
+ complete_request_written = true;
+ }
}
internal void InternalClose ()