Fix inaccurate parsing of HTTP headers (#417)

This commit is contained in:
Sviataslau Hankovich 2020-10-22 16:59:16 +03:00 committed by GitHub
parent 8fb36ef6cf
commit 65c5e875b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View file

@ -143,7 +143,6 @@ namespace Elsa.Activities.Http.Activities
set => SetState(value);
}
protected override async Task<ActivityExecutionResult> OnExecuteAsync(
WorkflowExecutionContext workflowContext,
CancellationToken cancellationToken)
@ -234,11 +233,11 @@ namespace Elsa.Activities.Http.Activities
);
var headers = new HeaderDictionary();
if (headersText != null)
if (!string.IsNullOrWhiteSpace(headersText))
{
var headersQuery =
from line in Regex.Split(headersText, "\\n", RegexOptions.Multiline)
let pair = line.Split(':', '=')
let pair = line.Split(new[] { ':', '=' }, 2)
select new KeyValuePair<string, string>(pair[0], pair[1]);
foreach (var header in headersQuery)
@ -258,7 +257,7 @@ namespace Elsa.Activities.Http.Activities
private bool GetMethodSupportsBody(string method)
{
var methods = new[] { "POST", "PUT", "PATCH" };
var methods = new[] { "POST", "PUT", "PATCH", "DELETE" };
return methods.Contains(method, StringComparer.InvariantCultureIgnoreCase);
}
}

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
@ -124,11 +124,11 @@ namespace Elsa.Activities.Http.Activities
cancellationToken
);
if (headersText != null)
if (!string.IsNullOrWhiteSpace(headersText))
{
var headersQuery =
from line in Regex.Split(headersText, "\\n", RegexOptions.Multiline)
let pair = line.Split(':', '=')
let pair = line.Split(new []{':', '='}, 2)
select new KeyValuePair<string, string>(pair[0], pair[1]);
foreach (var header in headersQuery)