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

Support aurelia-http-client in addition to fetch client #170

Open
don-bluelinegrid opened this issue Dec 13, 2016 · 5 comments
Open

Support aurelia-http-client in addition to fetch client #170

don-bluelinegrid opened this issue Dec 13, 2016 · 5 comments

Comments

@don-bluelinegrid
Copy link

In our project we have a use case for file upload using multipart-form data, and this simply will not work using the aurelia Fetch client. I won't go into a detailed explanation, but Fetch will not work correctly with borowsers to send mulipart-form data, because it doesn't set the content-type and boundary value in the request. As a result, this makes it necessary for us to use the aurelia-http-client for this specific call for file upload.

The aurelia-authentication package provides a FetchConfig class for automatically configuring the aurelia-fetch-client with the appropriate token interceptor. We need similar support for the aurelia-http-client, so that the token interceptor can be attached and the auth token injected.

How can we get this support in http-client?

Thanks,
Don

@paulvanbladel
Copy link
Owner

Hi Don,
Yeah sorry about that, I was indeed a bit too enthousiast about Fetch when completetly replacing aurelia-http client :(
Just wondering, isn't Fetch working correctly when you set content-type and boundary value? Or is Fetch simply unable to work with multi-part form data?
Warm regards
paul.

@don-bluelinegrid
Copy link
Author

Paul -

Regarding your question:

  1. Technically, you are not supposed to set the content-type on a FetchPOST with FormData, because it is supposed to send it using the correct format. However, this is not really the case.

  2. It is possible to set the content-type, but this won't be a solution, because for multipart form data we need a boundary value, which is dynamically generated and set by the browser, to correspond with the form data parts. So, the content type value should look something like this: Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryqSQQKo8Bw6dtofBP. We can't manually do this.

  3. In general, it seems that no, Fetch is not really up to the task of working properly with multipart form data. This is a pretty widely held conclusion, if you search.

So, what would it take to get a similar level of support for http-client? Meaning, just adding the token interceptor to http-client, so that the JWT token is auto-injected in the request made by http-client?

Thanks,
Don

@don-bluelinegrid
Copy link
Author

I guess someone else was asking for this also, back in September:

#154

@ClaudioNunes
Copy link

Also fetch client in current implementations does not deal with timeouts.
It would be nice that plugin also with aurelia-http-client that does deal with http timeouts.

@PeterWone
Copy link

PeterWone commented Apr 22, 2017

I can't think of a single use case in which fetch is functionally superior to XHR. Unfortunately I can think of numerous cases in which it is less functional.

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

No branches or pull requests

4 participants