Merge pull request #3587 from henricm/fix-set-no-delay-tcp-only
[mono.git] / mcs / class / System.Net.Http / System.Net.Http.Headers / RangeItemHeaderValue.cs
index 252b518128d52efabee932d91e03a6da6f2d9aac..405c976e8476f7e45fa2abd5fcd5ffc6f9b46c94 100644 (file)
@@ -32,6 +32,19 @@ namespace System.Net.Http.Headers
        {
                public RangeItemHeaderValue (long? from, long? to)
                {
+                       if (from == null && to == null)
+                               throw new ArgumentException ();
+
+                       if (from != null && to != null && from > to) {
+                               throw new ArgumentOutOfRangeException ("from");
+                       }
+
+                       if (from < 0)
+                               throw new ArgumentOutOfRangeException ("from");
+
+                       if (to < 0)
+                               throw new ArgumentOutOfRangeException ("to");
+
                        From = from;
                        To = to;
                }
@@ -54,5 +67,16 @@ namespace System.Net.Http.Headers
                {
                        return From.GetHashCode () ^ To.GetHashCode ();
                }
+
+               public override string ToString ()
+               {
+                       if (From == null)
+                               return "-" + To.Value;
+
+                       if (To == null)
+                               return From.Value + "-";
+
+                       return From.Value + "-" + To.Value;
+               }
        }
 }