Skip to content

Do not include URL fragment in HTTP request path - #5477

Open
ALancki1 wants to merge 2 commits into
racket:masterfrom
ALancki1:fix-remove-url-fragment
Open

ALancki1 wants to merge 2 commits into
racket:masterfrom
ALancki1:fix-remove-url-fragment

Conversation

@ALancki1

Copy link
Copy Markdown

Checklist

  • Bugfix
  • Feature
  • tests included
  • documentation

Description of change

This PR fixes an issue where the fragment portion of a URL (the part after #) is incorrectly included in HTTP requests made by get-impure-port.

According to RFC 3986, fragment identifiers are client-side only and must not be sent to the server. However, the current implementation includes the fragment in the request path.

This change removes the fragment when constructing the request URL, ensuring correct HTTP behavior.

Testing

I reproduced the issue locally using a TCP listener (nc -l -p 9303) and observed the fragment was included in the GET request:

GET /index.html#zzzz HTTP/1.1

After the fix, the request correctly becomes:

GET /index.html HTTP/1.1

The URL structure itself is unchanged; the fragment is only omitted when sending the HTTP request.

@jbclements

Copy link
Copy Markdown
Collaborator

So, is this in response to PR #5221 ? Also, forgive me for asking, are you human?

@ALancki1

Copy link
Copy Markdown
Author

Hi! Yes, this is in response to PR #5221, and yes I am human.

I can update the PR description to explicitly reference #5221 if that would be helpful.

@jbclements

Copy link
Copy Markdown
Collaborator

Excellent! I'm so glad to hear it, and of course I'm a bit sorry now to have asked. I think we've got the #5221 reference linked now. Now that I'm looking at this, it seems almost certain to me that this change should apply to the pure-port version too; is that in a function right near there? Or maybe the pure-port version actually calls this one?

@jbclements

Copy link
Copy Markdown
Collaborator

It might suffice just to run the test with pure-port?

@jbclements

Copy link
Copy Markdown
Collaborator

Also, have you taken a look to see what tests there are for the get-pure/impure-port functions?

@ALancki1

Copy link
Copy Markdown
Author

Thanks, that makes sense, I'll check whether the get-pure-port goes through the same path. I'll also look for existing tests around the get-pure/impure-port functions and update or add one accordingly.

@ALancki1

Copy link
Copy Markdown
Author

I checked get-pure-port, and it does go through the same underlying HTTP path via http://getpost-impure-port.

I also added a get-pure-port test alongside the existing get-impure-port coverage in url-port.rkt, and confirmed the added case passes locally.

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

Successfully merging this pull request may close these issues.

2 participants