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

Both content-type and Content-Type are set if contentType is set in uploadFile causing Bad Request #375

Closed
Cafe137 opened this issue Jul 26, 2021 · 1 comment · Fixed by #390

Comments

@Cafe137
Copy link
Collaborator

Cafe137 commented Jul 26, 2021

I am setting the contentType to text/html in bee.uploadFile.

When I print headers using --curl (swarm-cli), I see duplicate:

curl -X POST http://localhost:1633/bzz?name=index.html 
  -H "Content-Type: application/x-www-form-urlencoded"
  -H "content-type: text/html"

I followed this trail and found:

function setContentTypeIfUnset(headers: Record<string, unknown>, value: string) {
  if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
    headers['Content-Type'] = value
  }
}

I am wondering if there is a bug there, because of case sensitiveness? Maybe not, because axios handles it, but then which version does it choose?

@Cafe137
Copy link
Collaborator Author

Cafe137 commented Jul 26, 2021

I have removed the second part of the issue, since that was a bug in my proxy server implementation. 😅

@Cafe137 Cafe137 changed the title Content Type shows up twice in hook, appears once in request, yet fails to be parsed by bee Both content-type and Content-Type are set, if contentType is passed to uploadFile, causing Bad Request Jul 26, 2021
@Cafe137 Cafe137 changed the title Both content-type and Content-Type are set, if contentType is passed to uploadFile, causing Bad Request Both content-type and Content-Type are set if contentType is set in uploadFile causing Bad Request Jul 26, 2021
@AuHau AuHau linked a pull request Aug 18, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant