Adding Content-Type header to POST requests for .NET bindings
@@ -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;
@@ -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);
