Skip to content

Commit

Permalink
Adding Content-Type header to POST requests for .NET bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Nov 18, 2020
1 parent 47c76e2 commit 62bb990
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class HttpCommandExecutor : ICommandExecutor
private const string PngMimeType = "image/png";
private const string Utf8CharsetType = "utf-8";
private const string RequestAcceptHeader = JsonMimeType + ", " + PngMimeType;
private const string RequestContentTypeHeader = JsonMimeType + "; charset=" + Utf8CharsetType;
private const string UserAgentHeaderTemplate = "selenium/{0} (.net {1})";
private Uri remoteServerUri;
private TimeSpan serverResponseTimeout;
Expand Down Expand Up @@ -257,6 +258,10 @@ private async Task<HttpResponseInfo> MakeHttpRequest(HttpRequestInfo requestInfo

byte[] bytes = Encoding.UTF8.GetBytes(eventArgs.RequestBody);
requestMessage.Content = new ByteArrayContent(bytes, 0, bytes.Length);

MediaTypeHeaderValue contentTypeHeader = new MediaTypeHeaderValue(JsonMimeType);
contentTypeHeader.CharSet = Utf8CharsetType;
requestMessage.Content.Headers.ContentType = contentTypeHeader;
}

HttpResponseMessage responseMessage = await this.client.SendAsync(requestMessage);
Expand Down

0 comments on commit 62bb990

Please sign in to comment.