Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Request Body: Form data does not seem to pipe the contents of XML file #110

Closed
wboyle-erwin opened this issue Aug 7, 2017 · 43 comments
Labels

Comments

@wboyle-erwin
Copy link

wboyle-erwin commented Aug 7, 2017

  • VSCode Version: 1.14.2
  • OS Version: Windows 10 1703 15063.502
  • REST Client Version: 0.15.1

Steps to Reproduce:

Using the steps provided by the example
POST http://api.example.com/userupload HTTP/1.1
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file[0]"; filename="sample.xml"
Content-Type: application/xml

< C:\sample.xml
------WebKitFormBoundary7MA4YWxkTrZu0gW--

The actual content of the xml file sent is "< C:\sample.xml". It is not getting evaluated and the contents of the file are not piped in instead.

@Huachao
Copy link
Owner

Huachao commented Aug 8, 2017

@wboyle-erwin I can't reproduce this in my env, and does this file C:\sample.xml really exists in your system? You can verify this by Ctrl+Click the file name in editor, if exists, it will open the file in a new tab

@Huachao Huachao added the bug label Aug 8, 2017
@wboyle-erwin
Copy link
Author

wboyle-erwin commented Aug 8, 2017

sample.xml is just a sample statement. the actual file is different that i am trying to use. however, ctrl + click actually does nothing in my environment. the keybinding does not look to be defined.

@wboyle-erwin
Copy link
Author

was able to get ctrl + click enabled by enabling http mode with ctrl k, then m. Currently trying to figure out why it states "Unable to open 'xml file name': resource is not available" even though the location has the file.

@wboyle-erwin
Copy link
Author

making a path similar to file:///C:/sample.xml makes the ctrl+click resolve but still doesn't work

@Huachao
Copy link
Owner

Huachao commented Aug 8, 2017

@wboyle-erwin can you test whether escape the \ will work, like C:\\sample.xml or C:/sample.xml

@Huachao
Copy link
Owner

Huachao commented Aug 10, 2017

@wboyle-erwin could you please help to test the work around mentioned above?

@wboyle-erwin
Copy link
Author

wboyle-erwin commented Aug 11, 2017

Here is a post of the REST client snippet I have tried. Clicking the link (file:///) below seems to find the file in question. However, I get "failed to open stream: No such file or directory". Which to me seems like this is not sending any of the contents of the file with the request body.

POST https://dev.myerwin.io/dm/api/erwin-import HTTP/1.1
Authorization: Basic wboyle Testing123
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file[0]"; filename="sample_descriptions.xml"
Content-Type: application/xml

< file:///C:/Users/WilliamBoyle/Documents/sample_descriptions.xml
------WebKitFormBoundary7MA4YWxkTrZu0gW--

I have also tried the following:

< C:/Users/WilliamBoyle/Documents/sample_descriptions.xml
< C:\\Users\\WilliamBoyle\\Documents\\sample_descriptions.xml

Same error as above.

@Huachao
Copy link
Owner

Huachao commented Aug 14, 2017

@wboyle-erwin When you click the link (file:///), can you really open/find the file, in my test (finally on a windows machine), I can't repro your issue(even with no escape), but my code has bug in Ctrl+Click of file links(in non file:/// scheme).

@wboyle-erwin
Copy link
Author

with 0.15.2

Clicking the following provides an error now:
< file:///C:/Users/WilliamBoyle/Documents/sample_descriptions.xml

Clicking the following works now:

< C:/Users/WilliamBoyle/Documents/sample_descriptions.xml

The end result of Ctrl + Alt + R is the same unfortunately and doesn't pipe the contents of the file into the request body.

@Huachao
Copy link
Owner

Huachao commented Sep 12, 2017

@wboyle-erwin could you please sent the request to this url https://requestb.in/190tr451, and I will check the actual request you sent to server. Sorry for the incovenience

@wboyle-erwin
Copy link
Author

Sure. I sent the request.

@Huachao
Copy link
Owner

Huachao commented Sep 12, 2017

@wboyle-erwin as you can see here, your sent request seems already contains the xml file content in request body.

image

@wboyle-erwin
Copy link
Author

Inspecting the request body, i am not seeing the ending WebKitFormBoundary. Is there a limit to how much is sent?

@Huachao
Copy link
Owner

Huachao commented Sep 13, 2017

Do you mean you inspect your request body on your server side or the site I asked you to request for?

@ozh555
Copy link

ozh555 commented Jan 9, 2018

I had the same problem.

@Huachao
Copy link
Owner

Huachao commented Jan 9, 2018

@ozh555 could you please provide me some details about your OS and sample request, thanks in advance.

@ozh555
Copy link

ozh555 commented Jan 9, 2018

@Huachao
os: windows7 64
vsvode: 1.19.1
REST Client Version: 0.16.2

@ip = http://127.0.0.1:8080

POST {{ip}}/server/app
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="json"

{
"username":"123456"
}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="1.xml"
Content-Type: application/xml

< D:\123.xml
------WebKitFormBoundary7MA4YWxkTrZu0gW--

@Huachao
Copy link
Owner

Huachao commented Jan 9, 2018

@ozh555 thanks, could you also temporarily set the request url to https://requestb.in/1lx73751, and trigger a request, so that I can confirm your sent out request. Sorry for the inconvenience.

@Huachao
Copy link
Owner

Huachao commented Jan 9, 2018

@ozh555 as you can see here, sent out request already contains the XML content

@ozh555
Copy link

ozh555 commented Jan 9, 2018

@Huachao
Wow! It's true.
Maybe my server went wrong! But I use Postman can work,I do not know where is wrong。

@Huachao
Copy link
Owner

Huachao commented Jan 9, 2018

@ozh555 it still can be a bug of my code, could you please show me the error response before yo u dig into your server side code?

And another way to verify is that, you also send the request to https://requestb.in/1lx73751 in Postman, so that I can inspect the request difference between postman and mine. Thanks in advance

@Huachao
Copy link
Owner

Huachao commented Jan 9, 2018

@ozh555 except different boundaries, once difference I found is the Content-Type is different, mine is application/json and another is text/xml. So will you server work, if you change your request to text/xml of the file

@ip = http://127.0.0.1:8080

POST {{ip}}/server/app
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="json"

{
"username":"123456"
}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="1.xml"
Content-Type: text/xml

< D:\123.xml
------WebKitFormBoundary7MA4YWxkTrZu0gW--

@ozh555
Copy link

ozh555 commented Jan 9, 2018

@Huachao
Still can't work.
and vscode had problem:
image

@Huachao
Copy link
Owner

Huachao commented Jan 9, 2018

@ozh555 so the server didn't respond? Can postman still work now? Sorry for bothering you again and again

@ozh555
Copy link

ozh555 commented Jan 9, 2018

yes, server didn't respond.
postman work all the time.

@Huachao
Copy link
Owner

Huachao commented Jan 9, 2018

@ozh555 it's really strange, I will inspect this later when I have a Windows environment. One last thing, if you change back to application/xml, will the server respond in time? Thanks.

@ozh555
Copy link

ozh555 commented Jan 9, 2018

It's still the same.

@Huachao
Copy link
Owner

Huachao commented Jan 9, 2018

@ozh555 what do you mean same here? Does that mean if we revert to application/xml, the server can respond but not the expected response? Or since you use my extension, the server always don't return(just hang there)?

@ozh555
Copy link

ozh555 commented Jan 9, 2018

server always don't return。
and vscode always waiting。

@Huachao
Copy link
Owner

Huachao commented Jan 11, 2018

@ozh555 what's your server side stack(language + framework)?

@ozh555
Copy link

ozh555 commented Jan 11, 2018

Java-springmvc

@Huachao
Copy link
Owner

Huachao commented Feb 5, 2018

@ozh555 could you please to try again with latest version 0.17.0?

@Huachao
Copy link
Owner

Huachao commented Feb 8, 2018

@wboyle-erwin does this problem still exists in 0.17.0?

@Huachao
Copy link
Owner

Huachao commented Mar 14, 2018

@Platzer could you please to try again with latest version 0.17.0? Can you still repro

@Huachao
Copy link
Owner

Huachao commented Sep 9, 2018

If no one can repro this issue, I'd like to close it now, please feel free to reopen it

@Huachao Huachao closed this as completed Sep 9, 2018
@ozh555
Copy link

ozh555 commented Oct 11, 2018

I think this bug has since been fixed.

@newbienewbie
Copy link

newbienewbie commented Feb 25, 2019

I'm not sure whether I'm encountering the same bug.

Recently , when I post a file, it waits there , hangs and and never returns . However, if I send a payload in application/json format, this extension works as expected.

For example, I post an image as below:

POST https://eastus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceLandmarks=true&returnFaceAttributes=age,gender HTTP/1.1
Ocp-Apim-Subscription-Key: xxxx
Content-Type: application/octet-stream

< ./images/celebrities/gutianle-3.jpg

However, the same code worked flawlessly last month. I'm pretty sure there's nothing wrong with the server side.

What I have tired

I've tried to uninstall this extension, remove the folder under ~/.vscode/extensions/humao.rest-client-0.21.1 and re-install the latest version (v0.21.1) , but none of them works.

I'm wondering does this extension write to a temp file? What should I do ?

@Huachao
Copy link
Owner

Huachao commented Feb 25, 2019

@newbienewbie this is a known issue, and already fixed in #332 , and will publish this fix in next release

@newbienewbie
Copy link

@Huachao Hi, thanks for your quick response.

Is there a known date when the next version is released ?

@Huachao
Copy link
Owner

Huachao commented Feb 25, 2019

@newbienewbie earlier next week or later this week.

@newbienewbie
Copy link

@Huachao Got it . Thanks again for your great extension 💯 !

@Huachao
Copy link
Owner

Huachao commented Mar 6, 2019

@newbienewbie you can try the latest version to verify

@newbienewbie
Copy link

@Huachao Sorry for the late response. It works now . Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants