Skip to content

Commit 015d41f

Browse files
committed
Added all content headers
1 parent 470f318 commit 015d41f

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/RestSharp/KnownHeaders.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,21 @@
1313
// limitations under the License.
1414
//
1515

16+
// ReSharper disable InconsistentNaming
17+
1618
namespace RestSharp;
1719

1820
public static class KnownHeaders {
1921
public const string Accept = "Accept";
22+
public const string Allow = "Allow";
23+
public const string Expires = "Expires";
24+
public const string ContentDisposition = "Content-Disposition";
2025
public const string ContentEncoding = "Content-Encoding";
26+
public const string ContentLanguage = "Content-Language";
27+
public const string ContentLength = "Content-Length";
28+
public const string ContentLocation = "Content-Location";
29+
public const string ContentRange = "Content-Range";
2130
public const string ContentType = "Content-Type";
22-
public const string ContentDisposition = "Content-Disposition";
31+
public const string LastModified = "Last-Modified";
32+
public const string ContentMD5 = "Content-MD5";
2333
}

src/RestSharp/Request/RequestContent.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ class RequestContent : IDisposable {
2424
readonly RestRequest _request;
2525
readonly List<Stream> _streams = new();
2626

27-
internal static readonly string[] ContentHeaders = { ContentType, ContentEncoding, ContentDisposition };
27+
internal static readonly string[] ContentHeaders = {
28+
Allow, Expires,
29+
ContentDisposition, ContentEncoding, ContentLanguage, ContentLength, ContentLocation, ContentRange, ContentType, ContentMD5,
30+
LastModified
31+
};
2832

2933
HttpContent? Content { get; set; }
3034

@@ -147,6 +151,7 @@ void AddHeaders() {
147151
// We need some content to add content headers to it, so if necessary, we'll add empty content
148152
Content = new StringContent("");
149153
}
154+
150155
contentHeaders.ForEach(AddHeader);
151156

152157
void AddHeader(Parameter parameter) {

src/RestSharp/Request/RequestParameters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public RequestParameters AddDefaultParameters(RestClient client) {
5353

5454
// Add Accept header based on registered deserializers if none has been set by the caller.
5555
public RequestParameters AddAcceptHeader(RestClient client) {
56-
if (_requestParameters.All(p => !p.Name!.EqualsIgnoreCase("accept"))) {
56+
if (_requestParameters.All(p => !p.Name!.EqualsIgnoreCase(KnownHeaders.Accept))) {
5757
var accepts = string.Join(", ", client.AcceptedContentTypes);
58-
_requestParameters.Add(new Parameter("Accept", accepts, ParameterType.HttpHeader));
58+
_requestParameters.Add(new Parameter(KnownHeaders.Accept, accepts, ParameterType.HttpHeader));
5959
}
6060

6161
return this;

0 commit comments

Comments
 (0)