Skip to content

Commit

Permalink
Merge branch 'more-tests' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyzimarev committed Jan 9, 2022
2 parents 8b388fb + e15bc71 commit c4af0f4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/RestSharp/Enum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public enum DataFormat { Json, Xml, None }
/// </summary>
public enum Method {
Get, Post, Put, Delete, Head, Options,
Patch, Merge, Copy
Patch, Merge, Copy, Search
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/RestSharp/Parameters/ParametersCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ public bool Exists(Parameter parameter)

internal ParametersCollection GetQueryParameters(Method method) {
Func<Parameter, bool> condition =
!IsPostStyle(method)
!IsPost(method)
? p => p.Type is ParameterType.GetOrPost or ParameterType.QueryString
: p => p.Type is ParameterType.QueryString;

return new ParametersCollection(_parameters.Where(p => condition(p)));
}

internal ParametersCollection? GetContentParameters(Method method)
=> !IsPostStyle(method) ? null : new ParametersCollection(GetParameters<GetOrPostParameter>());
=> IsPost(method) ? new ParametersCollection(GetParameters<GetOrPostParameter>()) : null;

static bool IsPostStyle(Method method) => method is Method.Post or Method.Put or Method.Patch;
static bool IsPost(Method method) => method is Method.Post or Method.Put or Method.Patch;

public IEnumerator<Parameter> GetEnumerator() => _parameters.GetEnumerator();

Expand Down
7 changes: 4 additions & 3 deletions src/RestSharp/RestClient.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ static HttpMethod AsHttpMethod(Method method)
#else
Method.Patch => HttpMethod.Patch,
#endif
Method.Merge => new HttpMethod("MERGE"),
Method.Copy => new HttpMethod("COPY"),
_ => throw new ArgumentOutOfRangeException()
Method.Merge => new HttpMethod("MERGE"),
Method.Copy => new HttpMethod("COPY"),
Method.Search => new HttpMethod("SEARCH"),
_ => throw new ArgumentOutOfRangeException()
};
}

0 comments on commit c4af0f4

Please sign in to comment.