@@ -31,6 +31,11 @@ namespace RestSharp
31
31
/// </summary>
32
32
public class RestRequest : IRestRequest
33
33
{
34
+ /// <summary>
35
+ /// Local list of Allowed Decompresison Methods
36
+ /// </summary>
37
+ private readonly IList < DecompressionMethods > alloweDecompressionMethods ;
38
+
34
39
/// <summary>
35
40
/// Default constructor
36
41
/// </summary>
@@ -96,25 +101,20 @@ public RestRequest(Uri resource, Method method)
96
101
//resource.PathAndQuery not supported by Silverlight :(
97
102
}
98
103
99
- /// <summary>
100
- /// Local list of Allowed Decompresison Methods
101
- /// </summary>
102
- private readonly IList < DecompressionMethods > alloweDecompressionMethods ;
103
-
104
- /// <summary>
105
- /// List of Allowed Decompresison Methods
106
- /// </summary>
107
- public IList < DecompressionMethods > AllowedDecompressionMethods =>
108
- alloweDecompressionMethods . Any ( )
109
- ? alloweDecompressionMethods
110
- : new [ ] { DecompressionMethods . None , DecompressionMethods . Deflate , DecompressionMethods . GZip } ;
111
-
112
104
/// <summary>
113
105
/// Gets or sets a user-defined state object that contains information about a request and which can be later
114
106
/// retrieved when the request completes.
115
107
/// </summary>
116
108
public object UserState { get ; set ; }
117
109
110
+ /// <summary>
111
+ /// List of Allowed Decompresison Methods
112
+ /// </summary>
113
+ public IList < DecompressionMethods > AllowedDecompressionMethods =>
114
+ alloweDecompressionMethods . Any ( )
115
+ ? alloweDecompressionMethods
116
+ : new [ ] { DecompressionMethods . None , DecompressionMethods . Deflate , DecompressionMethods . GZip } ;
117
+
118
118
/// <summary>
119
119
/// Always send a multipart/form-data request - even when no Files are present.
120
120
/// </summary>
@@ -465,7 +465,8 @@ public IRestRequest AddParameter(string name, object value, string contentType,
465
465
}
466
466
467
467
/// <summary>
468
- /// Adds a parameter to the request or updates it with the given argument, if the parameter already exists in the request
468
+ /// Adds a parameter to the request or updates it with the given argument, if the parameter already exists in the
469
+ /// request
469
470
/// </summary>
470
471
/// <param name="p">Parameter to add</param>
471
472
/// <returns></returns>
@@ -483,8 +484,9 @@ public IRestRequest AddOrUpdateParameter(Parameter p)
483
484
}
484
485
485
486
/// <summary>
486
- /// Adds a HTTP parameter to the request or updates it with the given argument, if the parameter already exists in the request
487
- /// (QueryString for GET, DELETE, OPTIONS and HEAD; Encoded form for POST and PUT)
487
+ /// Adds a HTTP parameter to the request or updates it with the given argument, if the parameter already exists in the
488
+ /// request
489
+ /// (QueryString for GET, DELETE, OPTIONS and HEAD; Encoded form for POST and PUT)
488
490
/// </summary>
489
491
/// <param name="name">Name of the parameter</param>
490
492
/// <param name="value">Value of the parameter</param>
@@ -499,33 +501,37 @@ public IRestRequest AddOrUpdateParameter(string name, object value)
499
501
} ) ;
500
502
}
501
503
504
+ /// <inheritdoc />
502
505
/// <summary>
503
- /// Adds a HTTP parameter to the request or updates it with the given argument, if the parameter already exists in the request
504
- /// - GetOrPost: Either a QueryString value or encoded form value based on method
505
- /// - HttpHeader: Adds the name/value pair to the HTTP request's Headers collection
506
- /// - UrlSegment: Inserted into URL if there is a matching url token e.g. {AccountId}
507
- /// - RequestBody: Used by AddBody() (not recommended to use directly)
506
+ /// Adds a HTTP parameter to the request or updates it with the given argument, if the parameter already exists in the
507
+ /// request
508
+ /// - GetOrPost: Either a QueryString value or encoded form value based on method
509
+ /// - HttpHeader: Adds the name/value pair to the HTTP request's Headers collection
510
+ /// - UrlSegment: Inserted into URL if there is a matching url token e.g. {AccountId}
511
+ /// - RequestBody: Used by AddBody() (not recommended to use directly)
508
512
/// </summary>
509
513
/// <param name="name">Name of the parameter</param>
510
514
/// <param name="value">Value of the parameter</param>
511
515
/// <param name="type">The type of parameter to add</param>
512
516
/// <returns>This request</returns>
513
517
public IRestRequest AddOrUpdateParameter ( string name , object value , ParameterType type )
514
518
{
515
- return AddOrUpdateParameter ( new Parameter
516
- {
517
- Name = name ,
518
- Value = value ,
519
- Type = type
520
- } ) ;
519
+ return AddOrUpdateParameter (
520
+ new Parameter
521
+ {
522
+ Name = name ,
523
+ Value = value ,
524
+ Type = type
525
+ } ) ;
521
526
}
522
527
523
528
/// <summary>
524
- /// Adds a HTTP parameter to the request or updates it with the given argument, if the parameter already exists in the request
525
- /// - GetOrPost: Either a QueryString value or encoded form value based on method
526
- /// - HttpHeader: Adds the name/value pair to the HTTP request's Headers collection
527
- /// - UrlSegment: Inserted into URL if there is a matching url token e.g. {AccountId}
528
- /// - RequestBody: Used by AddBody() (not recommended to use directly)
529
+ /// Adds a HTTP parameter to the request or updates it with the given argument, if the parameter already exists in the
530
+ /// request
531
+ /// - GetOrPost: Either a QueryString value or encoded form value based on method
532
+ /// - HttpHeader: Adds the name/value pair to the HTTP request's Headers collection
533
+ /// - UrlSegment: Inserted into URL if there is a matching url token e.g. {AccountId}
534
+ /// - RequestBody: Used by AddBody() (not recommended to use directly)
529
535
/// </summary>
530
536
/// <param name="name">Name of the parameter</param>
531
537
/// <param name="value">Value of the parameter</param>
@@ -543,6 +549,7 @@ public IRestRequest AddOrUpdateParameter(string name, object value, string conte
543
549
} ) ;
544
550
}
545
551
552
+ /// <inheritdoc />
546
553
/// <summary>
547
554
/// Shortcut to AddParameter(name, value, HttpHeader) overload
548
555
/// </summary>
@@ -552,14 +559,18 @@ public IRestRequest AddOrUpdateParameter(string name, object value, string conte
552
559
public IRestRequest AddHeader ( string name , string value )
553
560
{
554
561
const string portSplit = @":\d+" ;
555
- Func < string , bool > invalidHost =
556
- host => Uri . CheckHostName ( Regex . Split ( host , portSplit ) [ 0 ] ) == UriHostNameType . Unknown ;
557
562
558
- if ( name == "Host" && invalidHost ( value ) )
563
+ bool InvalidHost ( string host )
564
+ {
565
+ return Uri . CheckHostName ( Regex . Split ( host , portSplit ) [ 0 ] ) == UriHostNameType . Unknown ;
566
+ }
567
+
568
+ if ( name == "Host" && InvalidHost ( value ) )
559
569
throw new ArgumentException ( "The specified value is not a valid Host header string." , "value" ) ;
560
570
return AddParameter ( name , value , ParameterType . HttpHeader ) ;
561
571
}
562
572
573
+ /// <inheritdoc />
563
574
/// <summary>
564
575
/// Shortcut to AddParameter(name, value, Cookie) overload
565
576
/// </summary>
@@ -594,17 +605,15 @@ public IRestRequest AddQueryParameter(string name, string value)
594
605
}
595
606
596
607
/// <summary>
597
- /// Add a Decompression Method to the request
608
+ /// Add a Decompression Method to the request
598
609
/// </summary>
599
610
/// <param name="decompressionMethod">None | GZip | Deflate</param>
600
611
/// <returns></returns>
601
612
public IRestRequest AddDecompressionMethod ( DecompressionMethods decompressionMethod )
602
613
{
603
- if ( ! this . alloweDecompressionMethods . Contains ( decompressionMethod ) )
604
- {
605
- this . alloweDecompressionMethods . Add ( decompressionMethod ) ;
606
- }
607
-
614
+ if ( ! alloweDecompressionMethods . Contains ( decompressionMethod ) )
615
+ alloweDecompressionMethods . Add ( decompressionMethod ) ;
616
+
608
617
return this ;
609
618
}
610
619
0 commit comments