2009-01-26 Gonzalo Paniagua Javier <gonzalo@novell.com>
[mono.git] / mcs / class / System / System.Net / HttpWebRequest.jvm.cs
index 2db90e69d76096061786285e08bae0d3cb43ace5..04fd44381c2b6bcd23561734bc4bd61dfb74c99f 100644 (file)
@@ -15,8 +15,6 @@ using System.Text;
 using System.Threading;\r
 using System.Net;\r
 \r
-\r
-\r
 namespace System.Net\r
 {\r
        [Serializable]\r
@@ -81,6 +79,8 @@ namespace System.Net
                {\r
                        [MonoTODO]\r
                        get{return _provider.GetX509Certificates();}\r
+                       [MonoNotSupported("")]\r
+                       set { throw new NotImplementedException (); }\r
                }\r
 \r
                public string Connection\r
@@ -93,7 +93,7 @@ namespace System.Net
 \r
                                string val = value;\r
                                if (val != null)\r
-                                       val = val.Trim ().ToLower ();\r
+                                       val = val.Trim ().ToLower (CultureInfo.InvariantCulture);\r
 \r
                                if (val == null || val.Length == 0)\r
                                {\r
@@ -178,7 +178,7 @@ namespace System.Net
                                        throw new InvalidOperationException("Connection already opened");\r
                                string val = value;\r
                                if (val != null)\r
-                                       val = val.Trim ().ToLower ();\r
+                                       val = val.Trim ().ToLower (CultureInfo.InvariantCulture);\r
 \r
                                if (val == null || val.Length == 0)\r
                                {\r
@@ -205,7 +205,7 @@ namespace System.Net
                }\r
 \r
                public DateTime IfModifiedSince\r
-               {
+               {\r
                        get\r
                        {\r
                                string str = Headers["If-Modified-Since"];\r
@@ -352,7 +352,7 @@ namespace System.Net
                                }\r
                                string val = value;\r
                                if (val != null)\r
-                                       val = val.Trim ().ToLower ();\r
+                                       val = val.Trim ().ToLower (CultureInfo.InvariantCulture);\r
 \r
                                if (val == null || val.Length == 0)\r
                                {\r
@@ -395,83 +395,83 @@ namespace System.Net
                {\r
                        _provider.Abort();\r
 //                     _connection.disconnect();\r
-//                     _haveResponse = true;
-//                     //aborted = true;
+//                     _haveResponse = true;\r
+//                     //aborted = true;\r
 //                     if (_asyncWrite != null)\r
-//                     {
-//                             GHWebAsyncResult r = _asyncWrite;
-//                             WebException wexc = new WebException ("Aborted.", WebExceptionStatus.RequestCanceled);
-//                             r.SetCompleted (false, wexc);
-//                             r.DoCallback ();
-//                             _asyncWrite = null;
-//                     }
-//
+//                     {\r
+//                             GHWebAsyncResult r = _asyncWrite;\r
+//                             WebException wexc = new WebException ("Aborted.", WebExceptionStatus.RequestCanceled);\r
+//                             r.SetCompleted (false, wexc);\r
+//                             r.DoCallback ();\r
+//                             _asyncWrite = null;\r
+//                     }\r
+//\r
 //                     if (_asyncRead != null)\r
-//                     {
-//                             GHWebAsyncResult r = _asyncRead;
-//                             WebException wexc = new WebException ("Aborted.", WebExceptionStatus.RequestCanceled);
-//                             r.SetCompleted (false, wexc);
-//                             r.DoCallback ();
-//                             _asyncRead = null;
-//                     }
-//
+//                     {\r
+//                             GHWebAsyncResult r = _asyncRead;\r
+//                             WebException wexc = new WebException ("Aborted.", WebExceptionStatus.RequestCanceled);\r
+//                             r.SetCompleted (false, wexc);\r
+//                             r.DoCallback ();\r
+//                             _asyncRead = null;\r
+//                     }\r
+//\r
 ////                   if (abortHandler != null)\r
-////                   {
+////                   {\r
 ////                           try\r
-////                           {
-////                                   abortHandler (this, EventArgs.Empty);
+////                           {\r
+////                                   abortHandler (this, EventArgs.Empty);\r
 ////                           }\r
-////                           catch {}
-////                           abortHandler = null;
-////                   }
-//
+////                           catch {}\r
+////                           abortHandler = null;\r
+////                   }\r
+//\r
 //                     if (_writeStream != null)\r
-//                     {
+//                     {\r
 //                             try\r
-//                             {
-//                                     _writeStream.Close ();
-//                                     _writeStream = null;
+//                             {\r
+//                                     _writeStream.Close ();\r
+//                                     _writeStream = null;\r
 //                             }\r
-//                             catch {}
-//                     }
-//
+//                             catch {}\r
+//                     }\r
+//\r
 //                     if (_response != null)\r
-//                     {
+//                     {\r
 //                             try\r
-//                             {
-//                                     _response.Close ();
-//                                     _response = null;
+//                             {\r
+//                                     _response.Close ();\r
+//                                     _response = null;\r
 //                             }\r
-//                             catch {}
+//                             catch {}\r
 //                     }\r
                }\r
 \r
-               public void AddRange (int range)
-               {
-                       AddRange ("bytes", range);
-               }
-
-               public void AddRange (int from, int to)
-               {
-                       AddRange ("bytes", from, to);
-               }
-
-               public void AddRange (string rangeSpecifier, int range)
-               {
+               public void AddRange (int range)\r
+               {\r
+                       AddRange ("bytes", range);\r
+               }\r
+\r
+               public void AddRange (int from, int to)\r
+               {\r
+                       AddRange ("bytes", from, to);\r
+               }\r
+\r
+               public void AddRange (string rangeSpecifier, int range)\r
+               {\r
                        if (rangeSpecifier == null)\r
                                throw new ArgumentNullException ("rangeSpecifier");\r
                        string value = Headers ["Range"];\r
                        if (value == null || value.Length == 0)\r
                                value = rangeSpecifier + "=";\r
-                       else if (value.ToLower ().StartsWith (rangeSpecifier.ToLower () + "="))\r
+                       else if (value.StartsWith (rangeSpecifier.ToLower () + "=", StringComparison.InvariantCultureIgnoreCase))\r
                                value += ",";\r
                        else\r
                                throw new InvalidOperationException ("rangeSpecifier");\r
-                       Headers.RemoveAndAdd ("Range", value + range + "-");
-               }
-
-               public void AddRange (string rangeSpecifier, int from, int to)
-               {
+                       Headers.RemoveAndAdd ("Range", value + range + "-");\r
+               }\r
+\r
+               public void AddRange (string rangeSpecifier, int from, int to)\r
+               {\r
                        if (rangeSpecifier == null)\r
                                throw new ArgumentNullException ("rangeSpecifier");\r
                        if (from < 0 || to < 0 || from > to)\r
@@ -479,11 +479,11 @@ namespace System.Net
                        string value = Headers ["Range"];\r
                        if (value == null || value.Length == 0)\r
                                value = rangeSpecifier + "=";\r
-                       else if (value.ToLower ().StartsWith (rangeSpecifier.ToLower () + "="))\r
+                       else if (value.StartsWith (rangeSpecifier.ToLower () + "=", StringComparison.InvariantCultureIgnoreCase))\r
                                value += ",";\r
                        else\r
                                throw new InvalidOperationException ("rangeSpecifier");\r
-                       Headers.RemoveAndAdd ("Range", value + from + "-" + to);
+                       Headers.RemoveAndAdd ("Range", value + from + "-" + to);\r
                }\r
 \r
                public override Stream GetRequestStream()\r
@@ -521,24 +521,24 @@ namespace System.Net
                        return _provider.GetResponse();\r
                }\r
                /*\r
-               private void CommonChecks (bool putpost)
-               {
-                       string method = _connection.getRequestMethod();
-
-                       if (method == null)
-                               throw new ProtocolViolationException ("Method is null.");
-
-                       bool keepAlive = _headers["Keep-Alive"] == null;
-                       bool allowBuffering = true;
-                       bool sendChunked = true;
-                       long contentLength = _connection.getContentLength();
-
-                       if (putpost && ((!keepAlive || (contentLength == -1 && !sendChunked)) && !allowBuffering))
-                               throw new ProtocolViolationException ("Content-Length not set");
-
-                       string transferEncoding = TransferEncoding;
-                       if (!sendChunked && transferEncoding != null && transferEncoding.Trim () != "")
-                               throw new ProtocolViolationException ("SendChunked should be true.");
+               private void CommonChecks (bool putpost)\r
+               {\r
+                       string method = _connection.getRequestMethod();\r
+\r
+                       if (method == null)\r
+                               throw new ProtocolViolationException ("Method is null.");\r
+\r
+                       bool keepAlive = _headers["Keep-Alive"] == null;\r
+                       bool allowBuffering = true;\r
+                       bool sendChunked = true;\r
+                       long contentLength = _connection.getContentLength();\r
+\r
+                       if (putpost && ((!keepAlive || (contentLength == -1 && !sendChunked)) && !allowBuffering))\r
+                               throw new ProtocolViolationException ("Content-Length not set");\r
+\r
+                       string transferEncoding = TransferEncoding;\r
+                       if (!sendChunked && transferEncoding != null && transferEncoding.Trim () != "")\r
+                               throw new ProtocolViolationException ("SendChunked should be true.");\r
                }\r
                */\r
 \r
@@ -548,7 +548,7 @@ namespace System.Net
                }\r
 \r
                public override Stream EndGetRequestStream(IAsyncResult asyncResult)\r
-               {
+               {\r
                        return _provider.EndGetRequestStream(asyncResult);\r
                }\r
 \r
@@ -600,6 +600,17 @@ namespace System.Net
 \r
 \r
                #endregion\r
+#if NET_2_0\r
+                public DecompressionMethods AutomaticDecompression\r
+                {\r
+                        get {\r
+                                throw new NotSupportedException ();\r
+                        }\r
+                        set {\r
+                                throw new NotSupportedException ();\r
+                        }\r
+                }\r
+#endif\r
 \r
        }\r
-}
\ No newline at end of file
+}\r