Skip to content

Commit

Permalink
It should be possible to set a custom content type
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Aug 16, 2019
1 parent 440080b commit 094eefd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Skybrud.Essentials.Http/HttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ public virtual IHttpResponse GetResponse(Action<HttpWebRequest> callback) {

// Get the bytes for the request body
byte[] bytes = Encoding.UTF8.GetBytes(Body);

// Set the content type
request.ContentType = request.ContentType;

// Set the length of the request body
SetRequestContentLength(request, bytes.Length);
Expand Down Expand Up @@ -315,7 +318,7 @@ public virtual IHttpResponse GetResponse(Action<HttpWebRequest> callback) {
byte[] bytes = Encoding.UTF8.GetBytes(dataString);

// Set the content type
request.ContentType = "application/x-www-form-urlencoded";
request.ContentType = request.ContentType ?? "application/x-www-form-urlencoded";

// Set the length of the request body
SetRequestContentLength(request, bytes.Length);
Expand Down

0 comments on commit 094eefd

Please sign in to comment.