Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/rhino.compute/ReverseProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Task LaunchChildren(HttpRequest request, HttpResponse response)
int parentProcessId = System.Convert.ToInt32(request.Query["parent"]);
if (Program.IsParentRhinoProcess(parentProcessId))
{
for (int i=0; i<children; i++)
for (int i = 0; i < children; i++)
{
ComputeChildren.LaunchCompute(false);
}
Expand Down Expand Up @@ -134,12 +134,24 @@ async Task<HttpResponseMessage> SendProxyRequest(HttpRequest initialRequest, Htt
if (initialRequest.Headers.TryGetValue(_apiKeyHeader, out var keyHeader))
req.Headers.Add(_apiKeyHeader, keyHeader.ToString());

var contentType = initialRequest.ContentType ?? string.Empty;
if (contentType.StartsWith("multipart/form-data", StringComparison.OrdinalIgnoreCase))
{
var streamContent = new StreamContent(initialRequest.Body);
streamContent.Headers.ContentType =
System.Net.Http.Headers.MediaTypeHeaderValue.Parse(contentType);
if (initialRequest.ContentLength.HasValue)
streamContent.Headers.ContentLength = initialRequest.ContentLength.Value;
req.Content = streamContent;
return await _client.SendAsync(req);
}

using (var stream = initialRequest.BodyReader.AsStream(false))
{
using (var sw = new System.IO.StreamReader(initialRequest.BodyReader.AsStream()))
{
string body = sw.ReadToEnd();
using (var stringContent = new StringContent(body, System.Text.Encoding.UTF8, "applicaton/json"))
using (var stringContent = new StringContent(body, System.Text.Encoding.UTF8, "application/json"))
{
req.Content = stringContent;
return await _client.SendAsync(req);
Expand Down