Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 159898e

Browse files
committed
Add TransferEncoding chunked
1 parent 3516bd7 commit 159898e

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/ServiceStack.Text/HttpRequestConfig.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ public class HttpRequestConfig
1212
public string? UserAgent { get; set; }
1313
public string? ContentType { get; set; }
1414
public string? Referer { get; set; }
15-
public string? Expect { get; set; }
15+
public string? Expect { get; set; }
16+
public string[]? TransferEncoding { get; set; }
17+
public bool? TransferEncodingChunked { get; set; }
1618
public NameValue? Authorization { get; set; }
1719
public LongRange? Range { get; set; }
1820
public List<NameValue> Headers { get; set; } = new();

src/ServiceStack.Text/HttpUtils.HttpClient.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,16 @@ public static HttpRequestMessage With(this HttpRequestMessage httpReq, Action<Ht
11111111
if (config.Expect != null)
11121112
httpReq.Headers.Expect.Add(new(config.Expect));
11131113

1114+
if (config.TransferEncodingChunked != null)
1115+
httpReq.Headers.TransferEncodingChunked = config.TransferEncodingChunked.Value;
1116+
else if (config.TransferEncoding?.Length > 0)
1117+
{
1118+
foreach (var enc in config.TransferEncoding)
1119+
{
1120+
httpReq.Headers.TransferEncoding.Add(new(enc));
1121+
}
1122+
}
1123+
11141124
foreach (var entry in headers)
11151125
{
11161126
httpReq.WithHeader(entry.Name, entry.Value);

src/ServiceStack.Text/HttpUtils.WebRequest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,11 @@ public static HttpWebRequest With(this HttpWebRequest httpReq, Action<HttpReques
11391139
if (config.Expect != null)
11401140
httpReq.Expect = config.Expect;
11411141

1142+
if (config.TransferEncodingChunked != null)
1143+
httpReq.TransferEncoding = "chunked";
1144+
else if (config.TransferEncoding?.Length > 0)
1145+
httpReq.TransferEncoding = string.Join(", ", config.TransferEncoding);
1146+
11421147
foreach (var entry in config.Headers)
11431148
{
11441149
httpReq.Headers[entry.Name] = entry.Value;

0 commit comments

Comments
 (0)