Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Added support for sending form data #141

Merged
merged 4 commits into from
Jun 4, 2019

Conversation

shrikster
Copy link
Contributor

@shrikster shrikster commented Mar 30, 2019

#7 #23
I Added support for sending form data including files .
that uses the params property inside the postData
when the mimeType is application/x-www-form-urlencoded all the param
All the params are passed as a simple url params in the body param1=value1&
param2=value2
when the mimeType is multipart/form-data
the name value pair are being converted to a FormData object that also can contains files.
I added a custom nunjuck filter called file.
it's just convert the file to his actual path , and prefix it with the string sendFile:
this is passed to the postData as a file steam .

@jgroom33
Copy link
Collaborator

jgroom33 commented Apr 2, 2019

the HAR spec looks a little different than what is implemented here.

Do you think there's a way to implement it closer to the spec?

"params": [
    {
        "name": "paramName",
        "value": "paramValue",
        "fileName": "example.pdf",
        "contentType": "application/pdf",
        "comment": ""
    }
]

List of posted parameters, if any (embedded in object).

name [string] - name of a posted parameter.
value [string, optional] - value of a posted parameter or content of a posted file.
fileName [string, optional] - name of a posted file.
contentType [string, optional] - content type of a posted file.
comment [string, optional] (new in 1.2) - A comment provided by the user or the application.

@shrikster
Copy link
Contributor Author

Sure NP
i was debating that issue with myself as well ...

@shrikster
Copy link
Contributor Author

shrikster commented Apr 6, 2019

the HAR spec looks a little different than what
is implemented here.

I tried my best to be as close to the HAR format as i can. (changed it from form to params)
regarding the files - I can't find an example on how will multiple files will be sent ..
@jgroom33
maybe you have an example for HAR with multiple files ?

@jgroom33
Copy link
Collaborator

jgroom33 commented Apr 6, 2019

Does the example file.strest.yml work as you expect?

Another option is to use contentType to trigger the file upload. This would eliminate the custom jinja filter.

But, I like the jinja filter approach also. The jinja filter approach avoids handling various contentTypes.

"params": [
    {
        "name": "paramName",
        "value": "..path.to.file",
        "fileName": "example.pdf",
        "contentType": "application/pdf"
    },
    {
        "name": "paramName",
        "value": "..path.to.file",
        "fileName": "example.pdf",
        "contentType": "application/pdf",
        "comment": ""
    }
]

@yaominator
Copy link

any ETA to merge this. This is a really useful patch.

@yaominator
Copy link

this tool is awesome, but missing the file upload is a pity.

@jgroom33 jgroom33 merged commit 112c00e into eykrehbein:master Jun 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants