Skip to content

Commit af291af

Browse files
Add web multipart/form-data test (#15550) (#15586)
* Add web test * Update filters * UNDO: comment-out ImageLoader, NativeAnimatedModule * Make response content clearer Co-authored-by: Julio César Rocha <JunielKatarn@users.noreply.github.com>
1 parent f91f49a commit af291af

4 files changed

Lines changed: 39 additions & 0 deletions

File tree

Directory.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
BaseOutDir;
106106
ReactNativeDir;
107107
ReactNativeWindowsDir;
108+
RnwNewArch;
108109
FollyDir;
109110
YogaDir;
110111
WinVer;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Add multipart/form-data test endpoint",
4+
"packageName": "react-native-windows",
5+
"email": "julio.rocha@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

vnext/TestWebSite/Microsoft/Office/OfficeJsTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Text;
2+
using System.Text.RegularExpressions;
23

34
namespace Microsoft.Office.Test
45
{
@@ -13,5 +14,31 @@ public static async Task Issue4144(HttpContext context)
1314
var bytes = Encoding.UTF8.GetBytes("Check headers: [Access-Control-Allow-Origin]");
1415
await response.Body.WriteAsync(bytes);
1516
}
17+
18+
public static async Task Issue5869(HttpContext context)
19+
{
20+
var response = context.Response;
21+
response.ContentType = "text/plain";
22+
response.StatusCode = 200;
23+
24+
var request = context.Request;
25+
26+
string? resBody;
27+
if (Regex.IsMatch(request.ContentType!, @"multipart/form-data(;\s+.*)?"))
28+
{
29+
resBody = $"Multipart form data with {request.Form.Count} entries";
30+
}
31+
else if (request.ContentType == "application/x-www-form-urlencoded")
32+
{
33+
resBody = $"URL-encoded form data with {request.Form.Count} entries";
34+
}
35+
else
36+
{
37+
resBody = $"Unknown Content-Type [{request.ContentType}]";
38+
}
39+
40+
var bytes = Encoding.UTF8.GetBytes(resBody);
41+
await response.Body.WriteAsync(bytes);
42+
}
1643
}
1744
}

vnext/TestWebSite/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ async Task DefaultRequestDelegate(HttpContext context)
8585
Microsoft.Office.Test.OfficeJsTests.Issue4144)
8686
.RequireCors(originPolicyName);
8787

88+
app.MapPost(
89+
"/officedev/office-js/issues/5869",
90+
Microsoft.Office.Test.OfficeJsTests.Issue5869);
91+
8892
#endregion Request Mappings
8993

9094
await app.RunAsync();

0 commit comments

Comments
 (0)