THRIFT-1159:THttpClient->Flush() issue (connection thru proxy)
authorJake Farrell <jfarrell@apache.org>
Fri, 18 May 2012 00:33:54 +0000 (00:33 +0000)
committerJake Farrell <jfarrell@apache.org>
Fri, 18 May 2012 00:33:54 +0000 (00:33 +0000)
Client: csharp
Patch: Joshua Samuel + Alex Gaas

Resolve HttpClient flush issues with proxy.

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1339934 13f79535-47bb-0310-9956-ffa450edef68

lib/csharp/src/Transport/THttpClient.cs

index 106f840..c875a43 100644 (file)
@@ -32,13 +32,21 @@ namespace Thrift.Transport
                private readonly Uri uri;
                private Stream inputStream;
                private MemoryStream outputStream = new MemoryStream();
-               private int connectTimeout = 0;
-               private int readTimeout = 0;
+
+        // Timeouts in milliseconds
+        private int connectTimeout = 30000;
+
+        private int readTimeout = 30000;
+
                private IDictionary<String, String> customHeaders = new Dictionary<string, string>();
 
+        private HttpWebRequest connection = null;
+        private IWebProxy proxy = WebRequest.DefaultWebProxy;
+
                public THttpClient(Uri u)
                {
                        uri = u;
+            connection = CreateRequest();
                }
 
                public int ConnectTimeout
@@ -65,6 +73,14 @@ namespace Thrift.Transport
                        }
                }
 
+        public IWebProxy Proxy
+        {
+            set
+            {
+                proxy = value;
+            }
+        }
+
                public override bool IsOpen
                {
                        get
@@ -192,7 +208,7 @@ namespace Thrift.Transport
                        }
 
 #if !SILVERLIGHT
-                       connection.Proxy = null;
+            connection.Proxy = proxy;
 #endif
 
             return connection;