Q: ASP Classic parse data from curl POST -F I have the following CURL request which pointing to my service:
curl -X POST \
  http://go.example.com/ \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Postman-Token: cf0c1ab5-08ff-1aa2-428e-24b855e1a61c' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F fff=vvvvv \
  -F rrrr=ddddd \
  -F xx=something

I'm trying to catch the xx paramter in classic ASP code.
I tried 'Request("xx")' and 'Request.Form("xx")'.
Do you have any idea?

A: This is from the CURL documentation

-F, --form 
(HTTP SMTP IMAP) For HTTP protocol family, this lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data according to RFC 2388.

When a form is submitted to Classic ASP using a content-type of multipart/form-data the only method available is Request.BinaryRead() as Request.Form is for application/x-www-form-urlencoded data.
Here is a quick example of calling Request.BinaryRead() to get you started:
<%
'Should be less than configured request limit in IIS.
Const maxRequestSizeLimit = ...
Dim dataSize: dataSize = Request.TotalBytes
Dim formData

If dataSize < maxRequestSizeLimit Then
  'Read bytes into a SafeArray
  formData = Request.BinaryRead(dataSize)
  'Once you have a SafeArray its up to you to process it.
  ...
Else
  Response.Status = "413 PAYLOAD TOO LARGE"
  Response.End
End If
%>


Parsing a SafeArray isn't easy
If you want to still use Request.Form you can do by specifying the form parameters in the CURL command using -d instead of -F. From the documentation;

-d, --data 
(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. Compare to -F, --form.

So the CURL command would be something like;
curl -X POST \
  http://go.mytest-service.com/ \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d fff=vvvvv \
  -d rrrr=ddddd \
  -d xx=something

You would then retrieve the xx parameter in Classic ASP using;
<%
Dim xx: xx = Request.Form("xx")
%>


Useful Links


*

*application/x-www-form-urlencoded or multipart/form-data?

*MSDN - Request.BinaryRead Method

*Example class for parsing a SafeArray (specifically the BuildUpload() method which takes a SafeArray and parses the binary)

*Example implemenation of a File Uploader class using Request.BinaryRead() on Planet Source Code
