18979: Switch common resource list request to use urlencoded post body for large...
authorStephen Smith <stephen@curii.com>
Wed, 5 Oct 2022 19:22:13 +0000 (15:22 -0400)
committerStephen Smith <stephen@curii.com>
Wed, 5 Oct 2022 19:22:13 +0000 (15:22 -0400)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

src/services/common-service/common-resource-service.test.ts
src/services/common-service/common-service.ts

index b94756ae02f18f0cf7f8ebaa85ec5dc950b17fbc..7f47f20ef77f296795b9003b1ef1df00ff679401 100644 (file)
@@ -136,8 +136,9 @@ describe("CommonResourceService", () => {
         await commonResourceService.list({ filters: tooBig });
         expect(axiosMock.history.get.length).toBe(0);
         expect(axiosMock.history.post.length).toBe(1);
-        expect(axiosMock.history.post[0].data.get('filters')).toBe(`[${tooBig}]`);
-        expect(axiosMock.history.post[0].params._method).toBe('GET');
+        const postParams = new URLSearchParams(axiosMock.history.post[0].data);
+        expect(postParams.get('filters')).toBe(`[${tooBig}]`);
+        expect(postParams.get('_method')).toBe('GET');
     });
 
     it("#list using GET when query string is not too big", async () => {
index f16a2024ad2c3a1775d4a5fb7e83f784e08554e4..bdae87ab4089a48e769c34fed83f6c0998418ba9 100644 (file)
@@ -156,7 +156,9 @@ export class CommonService<T> {
             );
         } else {
             // Using the POST special case to avoid URI length 414 errors.
-            const formData = new FormData();
+            // We must use urlencoded post body since api doesn't support form data
+            // const formData = new FormData();
+            const formData = new URLSearchParams();
             formData.append("_method", "GET");
             Object.keys(params).forEach(key => {
                 if (params[key] !== undefined) {
@@ -164,11 +166,7 @@ export class CommonService<T> {
                 }
             });
             return CommonService.defaultResponse(
-                this.serverApi.post(`/${this.resourceType}`, formData, {
-                    params: {
-                        _method: 'GET'
-                    }
-                }),
+                this.serverApi.post(`/${this.resourceType}`, formData, {}),
                 this.actions,
                 showErrors
             );