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

check if Content-Type header exists prior to examining the value #792

Merged

Conversation

krunalsshah
Copy link
Contributor

Problem
If the Content-Type header is missing in the GET request, results in an error, shown in the image below.
image (2)

Summary
Content-Type

A sender that generates a message containing a payload body SHOULD
generate a Content-Type header field in that message unless the
intended media type of the enclosed representation is unknown to the
sender.

For GET request payload body may not be present and result in error above.

Solution
Therefore the proposal is to check if Content-Type is present in the request header.
If the PR is approved, could we aim for a patch release?

@krunalsshah krunalsshah closed this Jul 8, 2020
@krunalsshah krunalsshah reopened this Jul 8, 2020
@krunalsshah
Copy link
Contributor Author

krunalsshah commented Jul 8, 2020

@JakeChampion @mislav seems the tests are failing from before? Locally npm test works fine.

$ npm test

> whatwg-fetch@3.0.0 pretest /Users/k0s00ly/workspace/walmart/fetch
> make

./node_modules/.bin/eslint --report-unused-disable-directives *.js test/*.js

> whatwg-fetch@3.0.0 test /Users/k0s00ly/workspace/walmart/fetch
> karma start ./test/karma.config.js && karma start ./test/karma-worker.config.js

08 07 2020 00:25:46.856:INFO [framework.detect-browsers]: The following browsers will be used: [ 'ChromeHeadlessNoSandbox', 'FirefoxHeadless', 'Safari' ]
08 07 2020 00:25:47.140:INFO [karma-server]: Karma v3.1.4 server started at http://0.0.0.0:9876/
08 07 2020 00:25:47.140:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox, FirefoxHeadless, Safari with concurrency unlimited
08 07 2020 00:25:47.146:INFO [launcher]: Starting browser ChromeHeadless
08 07 2020 00:25:47.154:INFO [launcher]: Starting browser FirefoxHeadless
08 07 2020 00:25:47.210:INFO [launcher]: Starting browser Safari
08 07 2020 00:25:47.752:INFO [HeadlessChrome 83.0.4103 (Mac OS X 10.15.5)]: Connected on socket UQ3vMP2qFuQoATBWAAAA with id 66841006
HeadlessChrome 83.0.4103 (Mac OS X 10.15.5): Executed 260 of 268 (skipped 8) SUCCESS (1.086 secs / 0.733 secs)
HeadlessChrome 83.0.4103 (Mac OS X 10.15.5): Executed 260 of 268 (skipped 8) SUCCESS (1.086 secs / 0.733 secs)
HeadlessChrome 83.0.4103 (Mac OS X 10.15.5): Executed 260 of 268 (skipped 8) SUCCESS (1.086 secs / 0.733 secs)
Firefox 78.0.0 (Mac OS X 10.15.0): Executed 263 of 268 (skipped 5) SUCCESS (1.63 secs / 1.455 secs)
Safari 13.1.1 (Mac OS X 10.15.5): Executed 261 of 268 (skipped 7) SUCCESS (0.803 secs / 0.487 secs)
TOTAL: 784 SUCCESS
08 07 2020 00:26:00.242:INFO [framework.detect-browsers]: The following browsers will be used: [ 'ChromeHeadlessNoSandbox', 'FirefoxHeadless', 'Safari' ]
08 07 2020 00:26:00.301:INFO [karma-server]: Karma v3.1.4 server started at http://0.0.0.0:9876/
08 07 2020 00:26:00.301:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox, FirefoxHeadless, Safari with concurrency unlimited
08 07 2020 00:26:00.304:INFO [launcher]: Starting browser ChromeHeadless
08 07 2020 00:26:00.311:INFO [launcher]: Starting browser FirefoxHeadless
08 07 2020 00:26:00.318:INFO [launcher]: Starting browser Safari
08 07 2020 00:26:00.921:INFO [HeadlessChrome 83.0.4103 (Mac OS X 10.15.5)]: Connected on socket Vkc_gcpwfzZn0xagAAAA with id 27404051
HeadlessChrome 83.0.4103 (Mac OS X 10.15.5): Executed 260 of 268 (skipped 8) SUCCESS (0.153 secs / 0.001 secs)
HeadlessChrome 83.0.4103 (Mac OS X 10.15.5): Executed 260 of 268 (skipped 8) SUCCESS (0.153 secs / 0.001 secs)
HeadlessChrome 83.0.4103 (Mac OS X 10.15.5): Executed 260 of 268 (skipped 8) SUCCESS (0.153 secs / 0.001 secs)
Firefox 78.0.0 (Mac OS X 10.15.0): Executed 263 of 268 (skipped 5) SUCCESS (0.139 secs / 0.001 secs)
Safari 13.1.1 (Mac OS X 10.15.5): Executed 261 of 268 (skipped 7) SUCCESS (0.098 secs / 0.001 secs)
TOTAL: 784 SUCCESS

Failing CI -> https://travis-ci.org/github/github/fetch/builds/693632830
https://travis-ci.org/github/github/fetch/builds/693319980
& more.

@gthiet
Copy link

gthiet commented Jul 8, 2020

I'm having this same issue...for get requests some api's are enforcing that the content type header not be present

@JakeChampion JakeChampion merged commit 3c0efb5 into JakeChampion:master Jul 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2021
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.

None yet

3 participants