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

Fails to load webpage with content-type "text/html;" #8506

Closed
swernerx opened this issue Sep 4, 2020 · 5 comments · Fixed by #9057
Closed

Fails to load webpage with content-type "text/html;" #8506

swernerx opened this issue Sep 4, 2020 · 5 comments · Fixed by #9057
Assignees

Comments

@swernerx
Copy link

swernerx commented Sep 4, 2020

Current behavior:

When loading a web page from our CDN (Azure) we do not have any issues in standard web browsers but when using Cypress. We receive the following error message:

Seems like it does the like the appended semicolon. I can't imagine that this additional semicolon used for adding e.g. a charset information is really that problematic.

Desired behavior:

I guess Cypress should tolerate all content-types starting with "text/html" instead of doing a strict string check here.

Test code to reproduce

Try running cypress again one of our CDN urls e.g.:

CYPRESS_BASE_URL=https://hconnectmanage-qa.azureedge.net/ yarn cypress run

The actual test is not relevant. It fails even before starting.

I modified your tiny repo to show it quickly:
https://github.com/swernerx/cypress-test-tiny/tree/content-type-issue

Versions

Cypress: v5.1
MacOS 10.15.6
Electron as bundled by Cypress

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Sep 4, 2020
@lbesson-della
Copy link

I agree with @swernerx here.
While the header azure is sending is probably not "correct", cypress could be less strict, since it's impossible (or very complicated) to change the headers sent by azure.

@flotwig
Copy link
Contributor

flotwig commented Oct 23, 2020

Technically, the header text/html; is invalid: https://tools.ietf.org/html/rfc7231#section-3.1.1.1 You need to supply a parameter after the ; for it to be valid.

However, it looks like Cypress wouldn't even recognize a valid parameter like text/html;charset=utf-8, or a valid uppercase content-type like Text/HTML:

const isResponseHtml = function (contentType, responseBuffer) {
let body
if (contentType) {
return contentType === 'text/html'
}
body = _.invoke(responseBuffer, 'toString')
if (body) {
return isHtml(body)
}
return false
}

This section of code should probably be updated to case-insensitively check that the content-type starts with text/html, since that is all that we really care about here.

Cypress also tries to check for valid HTML tags as a fallback, I'm not sure why this isn't working for your application, does it present valid HTML? - Edit: I see the issue now, it doesn't consider that unless the content-type tag is missing entirely

@cypress-bot cypress-bot bot added stage: ready for work The issue is reproducible and in scope and removed stage: needs investigating Someone from Cypress needs to look at this labels Nov 2, 2020
@cypress-bot cypress-bot bot added stage: work in progress There is an open PR for this issue [WIP] stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress There is an open PR for this issue [WIP] labels Nov 2, 2020
@sync-by-unito sync-by-unito bot assigned jennifer-shehane and unassigned flotwig Nov 2, 2020
@cypress-bot cypress-bot bot added stage: pending release There is a closed PR for this issue and removed stage: needs review The PR code is done & tested, needs review labels Nov 2, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 2, 2020

The code for this is done in cypress-io/cypress#9057, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@lbesson-della
Copy link

@swernerx FYI I don't know if you need a workaround for your specific case until this fix is available, but using the console or more easily via Microsoft Azure Storage Explorer, you can edit the Content-Type served by azure storage.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 9, 2020

Released in 5.6.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.6.0, please open a new issue.

@cypress-bot cypress-bot bot removed the stage: pending release There is a closed PR for this issue label Nov 9, 2020
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Nov 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants