2 // System.Net.WebConnection
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (C) 2003 Ximian, Inc (http://www.ximian.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Collections;
33 using System.Net.Sockets;
34 using System.Reflection;
35 using System.Security.Cryptography.X509Certificates;
37 using System.Threading;
54 object socketLock = new object ();
55 WebExceptionStatus status;
56 WaitCallback initConn;
59 static AsyncCallback readDoneDelegate = new AsyncCallback (ReadDone);
60 EventHandler abortHandler;
61 AbortHelper abortHelper;
63 internal WebConnectionData Data;
65 ChunkStream chunkStream;
70 HttpWebRequest priority_request;
71 NetworkCredential ntlm_credentials;
72 bool ntlm_authenticated;
79 Exception connect_exception;
80 static object classLock = new object ();
81 static Type sslStream;
82 static PropertyInfo piClient;
83 static PropertyInfo piServer;
84 static PropertyInfo piTrustFailure;
86 public WebConnection (WebConnectionGroup group, ServicePoint sPoint)
89 buffer = new byte [4096];
90 readState = ReadState.None;
91 Data = new WebConnectionData ();
92 initConn = new WaitCallback (InitConnection);
94 abortHelper = new AbortHelper ();
95 abortHelper.Connection = this;
96 abortHandler = new EventHandler (abortHelper.Abort);
100 public WebConnection Connection;
102 public void Abort (object sender, EventArgs args)
104 WebConnection other = ((HttpWebRequest) sender).WebConnection;
107 other.Abort (sender, args);
113 // The real condition is !(socket.Poll (0, SelectMode.SelectRead) || socket.Available != 0)
114 // but if there's data pending to read (!) we won't reuse the socket.
115 return (socket.Poll (0, SelectMode.SelectRead) == false);
118 void Connect (HttpWebRequest request)
121 if (socket != null && socket.Connected && status == WebExceptionStatus.Success) {
122 // Take the chunked stream to the expected state (State.None)
123 if (CanReuse () && CompleteChunkedRead ()) {
130 if (socket != null) {
136 IPHostEntry hostEntry = sPoint.HostEntry;
138 if (hostEntry == null) {
139 status = sPoint.UsesProxy ? WebExceptionStatus.ProxyNameResolutionFailure :
140 WebExceptionStatus.NameResolutionFailure;
144 WebConnectionData data = Data;
145 foreach (IPAddress address in hostEntry.AddressList) {
146 socket = new Socket (address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
147 IPEndPoint remote = new IPEndPoint (address, sPoint.Address.Port);
149 socket.SetSocketOption (SocketOptionLevel.Tcp, SocketOptionName.NoDelay, sPoint.UseNagleAlgorithm ? 0 : 1);
152 socket.NoDelay = !sPoint.UseNagleAlgorithm;
153 if (!sPoint.CallEndPointDelegate (socket, remote)) {
156 status = WebExceptionStatus.ConnectFailure;
162 socket.Connect (remote);
163 status = WebExceptionStatus.Success;
165 } catch (ThreadAbortException) {
166 // program exiting...
172 } catch (ObjectDisposedException exc) {
173 // socket closed from another thread
175 } catch (Exception exc) {
180 if (!request.Aborted)
181 status = WebExceptionStatus.ConnectFailure;
182 connect_exception = exc;
191 static void EnsureSSLStreamAvailable ()
194 if (sslStream != null)
197 // HttpsClientStream is an internal glue class in Mono.Security.dll
198 sslStream = Type.GetType ("Mono.Security.Protocol.Tls.HttpsClientStream, " +
199 Consts.AssemblyMono_Security, false);
201 if (sslStream == null) {
202 string msg = "Missing Mono.Security.dll assembly. " +
203 "Support for SSL/TLS is unavailable.";
205 throw new NotSupportedException (msg);
207 piClient = sslStream.GetProperty ("SelectedClientCertificate");
208 piServer = sslStream.GetProperty ("ServerCertificate");
209 piTrustFailure = sslStream.GetProperty ("TrustFailure");
213 bool CreateTunnel (HttpWebRequest request, Stream stream, out byte [] buffer)
215 StringBuilder sb = new StringBuilder ();
216 sb.Append ("CONNECT ");
217 sb.Append (request.Address.Host);
219 sb.Append (request.Address.Port);
220 sb.Append (" HTTP/");
221 if (request.ServicePoint.ProtocolVersion == HttpVersion.Version11)
226 sb.Append ("\r\nHost: ");
227 sb.Append (request.Address.Authority);
228 string challenge = Data.Challenge;
229 Data.Challenge = null;
230 bool have_auth = (request.Headers ["Proxy-Authorization"] != null);
232 sb.Append ("\r\nProxy-Authorization: ");
233 sb.Append (request.Headers ["Proxy-Authorization"]);
234 } else if (challenge != null && Data.StatusCode == 407) {
236 ICredentials creds = request.Proxy.Credentials;
237 Authorization auth = AuthenticationManager.Authenticate (challenge, request, creds);
239 sb.Append ("\r\nProxy-Authorization: ");
240 sb.Append (auth.Message);
243 sb.Append ("\r\n\r\n");
246 byte [] connectBytes = Encoding.Default.GetBytes (sb.ToString ());
247 stream.Write (connectBytes, 0, connectBytes.Length);
250 WebHeaderCollection result = ReadHeaders (request, stream, out buffer, out status);
251 if (!have_auth && result != null && status == 407) { // Needs proxy auth
252 Data.StatusCode = status;
253 Data.Challenge = result ["Proxy-Authenticate"];
255 } else if (status != 200) {
256 string msg = String.Format ("The remote server returned a {0} status code.", status);
257 HandleError (WebExceptionStatus.SecureChannelFailure, null, msg);
261 return (result != null);
264 WebHeaderCollection ReadHeaders (HttpWebRequest request, Stream stream, out byte [] retBuffer, out int status)
269 byte [] buffer = new byte [1024];
270 MemoryStream ms = new MemoryStream ();
271 bool gotStatus = false;
272 WebHeaderCollection headers = null;
275 int n = stream.Read (buffer, 0, 1024);
277 HandleError (WebExceptionStatus.ServerProtocolViolation, null, "ReadHeaders");
281 ms.Write (buffer, 0, n);
284 headers = new WebHeaderCollection ();
285 while (ReadLine (ms.GetBuffer (), ref start, (int) ms.Length, ref str)) {
287 if (ms.Length - start > 0) {
288 retBuffer = new byte [ms.Length - start];
289 Buffer.BlockCopy (ms.GetBuffer (), start, retBuffer, 0, retBuffer.Length);
299 int spaceidx = str.IndexOf (' ');
300 if (spaceidx == -1) {
301 HandleError (WebExceptionStatus.ServerProtocolViolation, null, "ReadHeaders2");
305 status = (int) UInt32.Parse (str.Substring (spaceidx + 1, 3));
311 bool CreateStream (HttpWebRequest request)
314 NetworkStream serverStream = new NetworkStream (socket, false);
316 if (request.Address.Scheme == Uri.UriSchemeHttps) {
318 EnsureSSLStreamAvailable ();
319 if (!reused || nstream == null || nstream.GetType () != sslStream) {
320 byte [] buffer = null;
321 if (sPoint.UseConnect) {
322 bool ok = CreateTunnel (request, serverStream, out buffer);
327 object[] args = new object [4] { serverStream,
328 request.ClientCertificates,
330 nstream = (Stream) Activator.CreateInstance (sslStream, args);
331 certsAvailable = false;
333 // we also need to set ServicePoint.Certificate
334 // and ServicePoint.ClientCertificate but this can
335 // only be done later (after handshake - which is
336 // done only after a read operation).
339 nstream = serverStream;
341 } catch (Exception) {
342 if (!request.Aborted)
343 status = WebExceptionStatus.ConnectFailure;
350 void HandleError (WebExceptionStatus st, Exception e, string where)
354 if (st == WebExceptionStatus.RequestCanceled)
355 Data = new WebConnectionData ();
358 if (e == null) { // At least we now where it comes from
361 throw new Exception ();
363 throw new Exception (new System.Diagnostics.StackTrace ().ToString ());
365 } catch (Exception e2) {
370 HttpWebRequest req = null;
371 if (Data != null && Data.request != null)
376 req.FinishedReading = true;
377 req.SetResponseError (st, e, where);
381 static void ReadDone (IAsyncResult result)
383 WebConnection cnc = (WebConnection) result.AsyncState;
384 WebConnectionData data = cnc.Data;
385 Stream ns = cnc.nstream;
393 nread = ns.EndRead (result);
394 } catch (Exception e) {
395 cnc.HandleError (WebExceptionStatus.ReceiveFailure, e, "ReadDone1");
400 cnc.HandleError (WebExceptionStatus.ReceiveFailure, null, "ReadDone2");
405 cnc.HandleError (WebExceptionStatus.ServerProtocolViolation, null, "ReadDone3");
410 nread += cnc.position;
411 if (cnc.readState == ReadState.None) {
412 Exception exc = null;
414 pos = cnc.GetResponse (cnc.buffer, nread);
415 } catch (Exception e) {
420 cnc.HandleError (WebExceptionStatus.ServerProtocolViolation, exc, "ReadDone4");
425 if (cnc.readState != ReadState.Content) {
427 int max = (est < cnc.buffer.Length) ? cnc.buffer.Length : est;
428 byte [] newBuffer = new byte [max];
429 Buffer.BlockCopy (cnc.buffer, 0, newBuffer, 0, nread);
430 cnc.buffer = newBuffer;
431 cnc.position = nread;
432 cnc.readState = ReadState.None;
439 WebConnectionStream stream = new WebConnectionStream (cnc);
441 string contentType = data.Headers ["Transfer-Encoding"];
442 cnc.chunkedRead = (contentType != null && contentType.ToLower ().IndexOf ("chunked") != -1);
443 if (!cnc.chunkedRead) {
444 stream.ReadBuffer = cnc.buffer;
445 stream.ReadBufferOffset = pos;
446 stream.ReadBufferSize = nread;
447 stream.CheckResponseInBuffer ();
448 } else if (cnc.chunkStream == null) {
450 cnc.chunkStream = new ChunkStream (cnc.buffer, pos, nread, data.Headers);
451 } catch (Exception e) {
452 cnc.HandleError (WebExceptionStatus.ServerProtocolViolation, e, "ReadDone5");
456 cnc.chunkStream.ResetBuffer ();
458 cnc.chunkStream.Write (cnc.buffer, pos, nread);
459 } catch (Exception e) {
460 cnc.HandleError (WebExceptionStatus.ServerProtocolViolation, e, "ReadDone6");
465 data.stream = stream;
467 if (!ExpectContent (data.StatusCode))
468 stream.ForceCompletion ();
470 data.request.SetResponseData (data);
473 static bool ExpectContent (int statusCode)
475 return (statusCode >= 200 && statusCode != 204 && statusCode != 304);
478 internal void GetCertificates ()
480 // here the SSL negotiation have been done
481 X509Certificate client = (X509Certificate) piClient.GetValue (nstream, null);
482 X509Certificate server = (X509Certificate) piServer.GetValue (nstream, null);
483 sPoint.SetCertificates (client, server);
484 certsAvailable = (server != null);
487 internal static void InitRead (object state)
489 WebConnection cnc = (WebConnection) state;
490 Stream ns = cnc.nstream;
493 int size = cnc.buffer.Length - cnc.position;
494 ns.BeginRead (cnc.buffer, cnc.position, size, readDoneDelegate, cnc);
495 } catch (Exception e) {
496 cnc.HandleError (WebExceptionStatus.ReceiveFailure, e, "InitRead");
500 int GetResponse (byte [] buffer, int max)
505 bool isContinue = false;
506 bool emptyFirstLine = false;
508 if (readState == ReadState.None) {
509 lineok = ReadLine (buffer, ref pos, max, ref line);
514 emptyFirstLine = true;
517 emptyFirstLine = false;
519 readState = ReadState.Status;
521 string [] parts = line.Split (' ');
522 if (parts.Length < 2)
525 if (String.Compare (parts [0], "HTTP/1.1", true) == 0) {
526 Data.Version = HttpVersion.Version11;
527 sPoint.SetVersion (HttpVersion.Version11);
529 Data.Version = HttpVersion.Version10;
530 sPoint.SetVersion (HttpVersion.Version10);
533 Data.StatusCode = (int) UInt32.Parse (parts [1]);
534 if (parts.Length >= 3)
535 Data.StatusDescription = String.Join (" ", parts, 2, parts.Length - 2);
537 Data.StatusDescription = "";
543 emptyFirstLine = false;
544 if (readState == ReadState.Status) {
545 readState = ReadState.Headers;
546 Data.Headers = new WebHeaderCollection ();
547 ArrayList headers = new ArrayList ();
548 bool finished = false;
550 if (ReadLine (buffer, ref pos, max, ref line) == false)
554 // Empty line: end of headers
559 if (line.Length > 0 && (line [0] == ' ' || line [0] == '\t')) {
560 int count = headers.Count - 1;
564 string prev = (string) headers [count] + line;
565 headers [count] = prev;
574 foreach (string s in headers)
575 Data.Headers.SetInternal (s);
577 if (Data.StatusCode == (int) HttpStatusCode.Continue) {
578 sPoint.SendContinue = true;
582 if (Data.request.ExpectContinue) {
583 Data.request.DoContinueDelegate (Data.StatusCode, Data.Headers);
584 // Prevent double calls when getting the
585 // headers in several packets.
586 Data.request.ExpectContinue = false;
589 readState = ReadState.None;
593 readState = ReadState.Content;
597 } while (emptyFirstLine || isContinue);
602 void InitConnection (object state)
604 HttpWebRequest request = (HttpWebRequest) state;
605 request.WebConnection = this;
610 keepAlive = request.KeepAlive;
611 Data = new WebConnectionData ();
612 Data.request = request;
618 if (status != WebExceptionStatus.Success) {
619 if (!request.Aborted) {
620 request.SetWriteStreamError (status, connect_exception);
626 if (!CreateStream (request)) {
630 WebExceptionStatus st = status;
631 if (Data.Challenge != null)
634 Exception cnc_exc = connect_exception;
635 connect_exception = null;
636 request.SetWriteStreamError (st, cnc_exc);
641 readState = ReadState.None;
642 request.SetWriteStream (new WebConnectionStream (this, request));
645 internal EventHandler SendRequest (HttpWebRequest request)
653 status = WebExceptionStatus.Success;
654 ThreadPool.QueueUserWorkItem (initConn, request);
657 queue.Enqueue (request);
668 if (queue.Count > 0) {
669 SendRequest ((HttpWebRequest) queue.Dequeue ());
674 internal void NextRead ()
677 Data.request.FinishedReading = true;
678 string header = (sPoint.UsesProxy) ? "Proxy-Connection" : "Connection";
679 string cncHeader = (Data.Headers != null) ? Data.Headers [header] : null;
680 bool keepAlive = (Data.Version == HttpVersion.Version11 && this.keepAlive);
681 if (cncHeader != null) {
682 cncHeader = cncHeader.ToLower ();
683 keepAlive = (this.keepAlive && cncHeader.IndexOf ("keep-alive") != -1);
686 if ((socket != null && !socket.Connected) ||
687 (!keepAlive || (cncHeader != null && cncHeader.IndexOf ("close") != -1))) {
692 if (priority_request != null) {
693 SendRequest (priority_request);
694 priority_request = null;
701 static bool ReadLine (byte [] buffer, ref int start, int max, ref string output)
703 bool foundCR = false;
704 StringBuilder text = new StringBuilder ();
707 while (start < max) {
708 c = (int) buffer [start++];
710 if (c == '\n') { // newline
711 if ((text.Length > 0) && (text [text.Length - 1] == '\r'))
716 } else if (foundCR) {
725 text.Append ((char) c);
728 if (c != '\n' && c != '\r')
731 if (text.Length == 0) {
733 return (c == '\n' || c == '\r');
739 output = text.ToString ();
744 internal IAsyncResult BeginRead (HttpWebRequest request, byte [] buffer, int offset, int size, AsyncCallback cb, object state)
747 if (Data.request != request)
748 throw new ObjectDisposedException (typeof (NetworkStream).FullName);
753 IAsyncResult result = null;
754 if (!chunkedRead || chunkStream.WantMore) {
756 result = nstream.BeginRead (buffer, offset, size, cb, state);
758 } catch (Exception) {
759 HandleError (WebExceptionStatus.ReceiveFailure, null, "chunked BeginRead");
765 WebAsyncResult wr = new WebAsyncResult (cb, state, buffer, offset, size);
766 wr.InnerAsyncResult = result;
767 if (result == null) {
768 // Will be completed from the data in ChunkStream
769 wr.SetCompleted (true, (Exception) null);
778 internal int EndRead (HttpWebRequest request, IAsyncResult result)
781 if (Data.request != request)
782 throw new ObjectDisposedException (typeof (NetworkStream).FullName);
784 throw new ObjectDisposedException (typeof (NetworkStream).FullName);
788 WebAsyncResult wr = null;
789 IAsyncResult nsAsync = ((WebAsyncResult) result).InnerAsyncResult;
790 if (chunkedRead && (nsAsync is WebAsyncResult)) {
791 wr = (WebAsyncResult) nsAsync;
792 IAsyncResult inner = wr.InnerAsyncResult;
793 if (inner != null && !(inner is WebAsyncResult))
794 nbytes = nstream.EndRead (inner);
795 } else if (!(nsAsync is WebAsyncResult)) {
796 nbytes = nstream.EndRead (nsAsync);
797 wr = (WebAsyncResult) result;
801 bool done = (nbytes == 0);
803 chunkStream.WriteAndReadBack (wr.Buffer, wr.Offset, wr.Size, ref nbytes);
804 if (!done && nbytes == 0 && chunkStream.WantMore)
805 nbytes = EnsureRead (wr.Buffer, wr.Offset, wr.Size);
806 } catch (Exception e) {
807 if (e is WebException)
810 throw new WebException ("Invalid chunked data.", e,
811 WebExceptionStatus.ServerProtocolViolation, null);
814 if ((done || nbytes == 0) && chunkStream.ChunkLeft != 0) {
815 HandleError (WebExceptionStatus.ReceiveFailure, null, "chunked EndRead");
816 throw new WebException ("Read error", null, WebExceptionStatus.ReceiveFailure, null);
820 return (nbytes != 0) ? nbytes : -1;
823 // To be called on chunkedRead when we can read no data from the ChunkStream yet
824 int EnsureRead (byte [] buffer, int offset, int size)
826 byte [] morebytes = null;
828 while (nbytes == 0 && chunkStream.WantMore) {
829 int localsize = chunkStream.ChunkLeft;
830 if (localsize <= 0) // not read chunk size yet
832 else if (localsize > 16384)
835 if (morebytes == null || morebytes.Length < localsize)
836 morebytes = new byte [localsize];
838 int nread = nstream.Read (morebytes, 0, localsize);
842 chunkStream.Write (morebytes, 0, nread);
843 nbytes += chunkStream.Read (buffer, offset + nbytes, size - nbytes);
849 bool CompleteChunkedRead()
851 if (!chunkedRead || chunkStream == null)
854 while (chunkStream.WantMore) {
855 int nbytes = nstream.Read (buffer, 0, buffer.Length);
857 return false; // Socket was disconnected
859 chunkStream.Write (buffer, 0, nbytes);
865 internal IAsyncResult BeginWrite (HttpWebRequest request, byte [] buffer, int offset, int size, AsyncCallback cb, object state)
868 if (Data.request != request)
869 throw new ObjectDisposedException (typeof (NetworkStream).FullName);
874 IAsyncResult result = null;
876 result = nstream.BeginWrite (buffer, offset, size, cb, state);
877 } catch (Exception) {
878 status = WebExceptionStatus.SendFailure;
885 internal void EndWrite2 (HttpWebRequest request, IAsyncResult result)
888 if (Data.request != request)
889 throw new ObjectDisposedException (typeof (NetworkStream).FullName);
891 throw new ObjectDisposedException (typeof (NetworkStream).FullName);
895 nstream.EndWrite (result);
896 } catch (Exception exc) {
897 status = WebExceptionStatus.SendFailure;
898 if (exc.InnerException != null)
899 throw exc.InnerException;
904 internal bool EndWrite (HttpWebRequest request, IAsyncResult result)
907 if (Data.request != request)
908 throw new ObjectDisposedException (typeof (NetworkStream).FullName);
910 throw new ObjectDisposedException (typeof (NetworkStream).FullName);
914 nstream.EndWrite (result);
917 status = WebExceptionStatus.SendFailure;
922 internal int Read (HttpWebRequest request, byte [] buffer, int offset, int size)
925 if (Data.request != request)
926 throw new ObjectDisposedException (typeof (NetworkStream).FullName);
935 result = nstream.Read (buffer, offset, size);
936 done = (result == 0);
941 chunkStream.WriteAndReadBack (buffer, offset, size, ref result);
942 if (!done && result == 0 && chunkStream.WantMore)
943 result = EnsureRead (buffer, offset, size);
944 } catch (Exception e) {
945 HandleError (WebExceptionStatus.ReceiveFailure, e, "chunked Read1");
949 if ((done || result == 0) && chunkStream.WantMore) {
950 HandleError (WebExceptionStatus.ReceiveFailure, null, "chunked Read2");
951 throw new WebException ("Read error", null, WebExceptionStatus.ReceiveFailure, null);
954 } catch (Exception e) {
955 HandleError (WebExceptionStatus.ReceiveFailure, e, "Read");
961 internal bool Write (HttpWebRequest request, byte [] buffer, int offset, int size, ref string err_msg)
965 if (Data.request != request)
966 throw new ObjectDisposedException (typeof (NetworkStream).FullName);
972 nstream.Write (buffer, offset, size);
973 // here SSL handshake should have been done
974 if (ssl && !certsAvailable)
976 } catch (Exception e) {
978 WebExceptionStatus wes = WebExceptionStatus.SendFailure;
979 string msg = "Write: " + err_msg;
980 if (e is WebException) {
981 HandleError (wes, e, msg);
985 // if SSL is in use then check for TrustFailure
986 if (ssl && (bool) piTrustFailure.GetValue (nstream, null)) {
987 wes = WebExceptionStatus.TrustFailure;
988 msg = "Trust failure";
991 HandleError (wes, e, msg);
997 internal void Close (bool sendNext)
1000 if (nstream != null) {
1007 if (socket != null) {
1015 Data = new WebConnectionData ();
1021 void Abort (object sender, EventArgs args)
1025 HttpWebRequest req = (HttpWebRequest) sender;
1026 if (Data.request == req) {
1027 if (!req.FinishedReading) {
1028 status = WebExceptionStatus.RequestCanceled;
1030 if (queue.Count > 0) {
1031 Data.request = (HttpWebRequest) queue.Dequeue ();
1032 SendRequest (Data.request);
1038 req.FinishedReading = true;
1039 req.SetResponseError (WebExceptionStatus.RequestCanceled, null, "User aborted");
1040 if (queue.Count > 0 && queue.Peek () == sender) {
1042 } else if (queue.Count > 0) {
1043 object [] old = queue.ToArray ();
1045 for (int i = old.Length - 1; i >= 0; i--) {
1046 if (old [i] != sender)
1047 queue.Enqueue (old [i]);
1054 internal void ResetNtlm ()
1056 ntlm_authenticated = false;
1057 ntlm_credentials = null;
1058 unsafe_sharing = false;
1061 internal bool Busy {
1062 get { lock (this) return busy; }
1065 internal bool Connected {
1068 return (socket != null && socket.Connected);
1073 // -Used for NTLM authentication
1074 internal HttpWebRequest PriorityRequest {
1075 set { priority_request = value; }
1078 internal bool NtlmAuthenticated {
1079 get { return ntlm_authenticated; }
1080 set { ntlm_authenticated = value; }
1083 internal NetworkCredential NtlmCredential {
1084 get { return ntlm_credentials; }
1085 set { ntlm_credentials = value; }
1089 internal bool UnsafeAuthenticatedConnectionSharing {
1090 get { return unsafe_sharing; }
1091 set { unsafe_sharing = value; }