sasjs / server

Build Apps on Base SAS
https://server.sasjs.io
MIT License
20 stars 3 forks source link

POST stp/execute not accepting file inputs from proc http #149

Closed allanbowe closed 2 years ago

allanbowe commented 2 years ago

It's working from javascript so is probably some hidden little issue somewhere.

I can see the request arriving in the server log:

1|dwpci  | POST /SASjsApi/stp/execute?_program=/tmp/tests/sasjs/core/20220427_214125774_13731_138/services/sendObj&_debug=131 200 41512 - 344.819 ms
1|dwpci  | session crashed 20220427214118-84069-1651095678354 Error: Command failed: /opt/sas/sas9/SASHome/SASFoundation/9.4/bin/sas_u8 -SYSIN /tmp/frsdwpci/sessions/20220427214118-84069-1651095678354/code.sas -LOG /tmp/frsdwpci/sessions/20220427214118-84069-1651095678354/log.log -PRINT /tmp/frsdwpci/sessions/20220427214118-84069-1651095678354/output.lst -WORK /tmp/frsdwpci/sessions/20220427214118-84069-1651095678354 -AUTOEXEC /tmp/frsdwpci/sessions/20220427214118-84069-1651095678354/autoexec.sas 

Here's the hex dump of the payload being sent:

> Content-Type: application/x-www-form-urlencoded

> 

> 00007F5CB00E1FC0: 2D 2D 4D 43 61 33 38 64 63 31 66 61 31 34 61 35 --MCa38dc1fa14a5
> 00007F5CB00E1FD0: 61 63 34 38 62 30 36 30 63 64 33 35 66 62 64 35 ac48b060cd35fbd5
> 00007F5CB00E1FE0: 65 31 0D 0A 43 6F 6E 74 65 6E 74 2D 44 69 73 70 e1..Content-Disp
> 00007F5CB00E1FF0: 6F 73 69 74 69 6F 6E 3A 20 66 6F 72 6D 2D 64 61 osition: form-da
> 00007F5CB00E2000: 74 61 3B 20 6E 61 6D 65 3D 22 73 6F 6D 65 64 61 ta; name="someda
> 00007F5CB00E2010: 74 61 31 22 3B 20 66 69 6C 65 6E 61 6D 65 3D 22 ta1"; filename="
> 00007F5CB00E2020: 73 6F 6D 65 64 61 74 61 31 2E 63 73 76 22 0D 0A somedata1.csv"..
> 00007F5CB00E2030: 43 6F 6E 74 65 6E 74 2D 54 79 70 65 3A 20 74 65 Content-Type: te
> 00007F5CB00E2040: 78 74 2F 70 6C 61 69 6E 0D 0A 0D 0A 58 3A 62 65 xt/plain....X:be
> 00007F5CB00E2050: 73 74 2E 20 59 3A 24 63 68 61 72 37 2E 20 5A 3A st. Y:$char7. Z:
> 00007F5CB00E2060: 62 65 73 74 2E 0D 0A 31 2C 22 20 20 74 22 22 77 best...1,"  t""w
> 00007F5CB00E2070: 22 22 6F 22 2C 2E 5A 0D 0A 0D 0A 2D 2D 4D 43 61 ""o",.Z....--MCa
> 00007F5CB00E2080: 33 38 64 63 31 66 61 31 34 61 35 61 63 34 38 62 38dc1fa14a5ac48b
> 00007F5CB00E2090: 30 36 30 63 64 33 35 66 62 64 35 65 31 2D 2D 0D 060cd35fbd5e1--.
> 00007F5CB00E20A0: 0A 43 6F 6E 74 65 6E 74 2D 44 69 73 70 6F 73 69 .Content-Disposi
> 00007F5CB00E20B0: 74 69 6F 6E 3A 20 66 6F 72 6D 2D 64 61 74 61 3B tion: form-data;
> 00007F5CB00E20C0: 20 6E 61 6D 65 3D 22 73 6F 6D 65 64 61 74 61 32  name="somedata2
> 00007F5CB00E20D0: 22 3B 20 66 69 6C 65 6E 61 6D 65 3D 22 73 6F 6D "; filename="som
> 00007F5CB00E20E0: 65 64 61 74 61 32 2E 63 73 76 22 0D 0A 43 6F 6E edata2.csv"..Con
> 00007F5CB00E20F0: 74 65 6E 74 2D 54 79 70 65 3A 20 74 65 78 74 2F tent-Type: text/
> 00007F5CB00E2100: 70 6C 61 69 6E 0D 0A 0D 0A 58 3A 62 65 73 74 2E plain....X:best.
> 00007F5CB00E2110: 20 59 3A 24 63 68 61 72 37 2E 20 5A 3A 62 65 73  Y:$char7. Z:bes
> 00007F5CB00E2120: 74 2E 0D 0A 31 2C 22 20 20 74 22 22 77 22 22 6F t...1,"  t""w""o
> 00007F5CB00E2130: 22 2C 2E 5A 0D 0A 0D 0A 2D 2D 4D 43 61 33 38 64 ",.Z....--MCa38d
> 00007F5CB00E2140: 63 31 66 61 31 34 61 35 61 63 34 38 62 30 36 30 c1fa14a5ac48b060
> 00007F5CB00E2150: 63 64 33 35 66 62 64 35 65 31 2D 2D 0D 0A       cd35fbd5e1--..  
< HTTP/1.1 200 OK

< X-Powered-By: Express

< Content-Type: application/json; charset=utf-8

< Content-Length: 41512

< ETag: W/"a228-x8O8nGZnFHu6VmQiZJaBCaZGMBo"

< Date: Wed, 27 Apr 2022 21:41:26 GMT

< Connection: keep-alive

< Keep-Alive: timeout=5

< 

NOTE: 200 OK
NOTE: PROCEDURE HTTP used (Total process time):
      real time           0.34 seconds
      cpu time            0.00 seconds
allanbowe commented 2 years ago

My bad - I'd forgotten the line below in the header section

put "Content-Type: multipart/form-data; boundary=&boundary";