forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpExt.cs
More file actions
27 lines (25 loc) · 734 Bytes
/
HttpExt.cs
File metadata and controls
27 lines (25 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
namespace ServiceStack
{
public static class HttpExt
{
public static bool HasNonAscii(string s)
{
if (!string.IsNullOrEmpty(s))
{
foreach (var c in s)
{
if (c > 127)
return true;
}
}
return false;
}
public static string GetDispositionFileName(string fileName)
{
if (!HasNonAscii(fileName))
return $"filename=\"{fileName}\"";
var encodedFileName = ClientConfig.EncodeDispositionFileName(fileName);
return $"filename=\"{encodedFileName}\"; filename*=UTF-8''{encodedFileName}";
}
}
}