Skip to content

Wrong HTTPS status error messages are displayed in browser / Pjax repeats request even if HTML present #357

Description

@misog

Describe the bug

Hi, this issue is caused by Pjax revisits as described here: #342

The problem is worse however. For example, when user uploads too large file, the server response "413 Request Entity Too Large" should be displayed to user. For example, this is returned by nginx:

<html>
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx</center>
</body>
</html>

But now Pjax tries to revisit that URL and that will produce this error instead:

Oops! An Error Occurred
The server returned a "405 Method Not Allowed".

The core of the problem is that Pjax makes additional request without user consent (revisit).

To reproduce

  1. Make any form POST request to URL in a way that generates status code >=400 and where the URL is POST-only
  2. See the error message
  3. The error message is wrong (Pjax tries to GET that URL which is POST-only)

Expected behavior

  • Correct server error message should be displayed in the browser.
  • Pjax should not repeat a request if there is HTML content to show in the first response.

Possible solutions

Pjax probably checks mime type or something in header or status code to decide if to repeat request.

One solution to this problem is to check if there is any HTML content even if there is error status and then NOT repeat request (revisit) and instead run document.write(htm_error). Or user-provided handler for error output can be run (where I would call document.write and show the HTML of the error message).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions