Skip to content

Commit 62bb990

Browse files
committed
Adding Content-Type header to POST requests for .NET bindings
1 parent 47c76e2 commit 62bb990

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

dotnet/src/webdriver/Remote/HttpCommandExecutor.cs

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class HttpCommandExecutor : ICommandExecutor
3939
private const string PngMimeType = "image/png";
4040
private const string Utf8CharsetType = "utf-8";
4141
private const string RequestAcceptHeader = JsonMimeType + ", " + PngMimeType;
42+
private const string RequestContentTypeHeader = JsonMimeType + "; charset=" + Utf8CharsetType;
4243
private const string UserAgentHeaderTemplate = "selenium/{0} (.net {1})";
4344
private Uri remoteServerUri;
4445
private TimeSpan serverResponseTimeout;
@@ -257,6 +258,10 @@ private async Task<HttpResponseInfo> MakeHttpRequest(HttpRequestInfo requestInfo
257258

258259
byte[] bytes = Encoding.UTF8.GetBytes(eventArgs.RequestBody);
259260
requestMessage.Content = new ByteArrayContent(bytes, 0, bytes.Length);
261+
262+
MediaTypeHeaderValue contentTypeHeader = new MediaTypeHeaderValue(JsonMimeType);
263+
contentTypeHeader.CharSet = Utf8CharsetType;
264+
requestMessage.Content.Headers.ContentType = contentTypeHeader;
260265
}
261266

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

0 commit comments

Comments
 (0)