Skip to content

hs.http: include the final URL in responses - #400

Open
asp55 wants to merge 1 commit into
cmsj:mainfrom
asp55:hs-http-response-url
Open

asp55 wants to merge 1 commit into
cmsj:mainfrom
asp55:hs-http-response-url

Conversation

@asp55

@asp55 asp55 commented Nov 18, 2026

Copy link
Copy Markdown

Summary

Every hs.http request (get, post, put, doRequest) now resolves with a url property alongside status, body and headers:

hs.http.get("http://example.com/old").then(r => console.log(r.url))
// -> "http://example.com/new" if /old redirected to /new

url is the URL that actually answered the request, so after a redirect it differs from the one that was requested. This is useful for resolving short links and detecting redirects without handling them yourself.

Behaviour

  • Successful requests: url is the final URL after any redirects.
  • Failed requests (network error): status is -1 as before, and url is "".
    Like the other fields, it is always present, so callers don't need to check for
    undefined.
  • Purely additive: status, body and headers are unchanged.

Changes

  • HSHTTPModule.swift: read HTTPURLResponse.url and add it to the resolved object;
    update the Returns: docstrings for all four request methods.
  • docs/migration-guide.md: the hs.http entry now documents url.

Tests

Both are loopback only, with no external network.

  • A local hs.httpserver answers /start with a 302 to /final. The test checks that
    url is the /final URL and status is 200.
  • A request to a refused port resolves with status == -1 and url == "".

Tests and npm run docs:test pass locally.

AI disclosure

Tool: Claude Code (Claude Sonnet 5.5), run in VS Code.

  • Written by me: the url change in HSHTTPModule.swift (the module's response handling).
  • AI-assisted: the two new tests, the migration guide wording, the commit message and this PR description. Claude drafted them. I reviewed and edited them, and ran the tests myself.

Changelog-Added: url property on hs.http responses, giving the final URL after any redirects

Responses from get, post, put and doRequest now carry the URL that
answered the request, after any redirects. Failed requests resolve with
status -1 and an empty url.

Changelog-Added: `url` property on `hs.http` responses, giving the final URL after any redirects
@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds the final response URL to hs.http results without changing the existing response fields.

  • HTTP responses now include the URL that answered.

No actionable issues found. The macOS tests were not run in this Linux environment.

Reviews (1) · Last reviewed commit: "feat(hs.http): include the final URL in ..." · Reviewed by Greptile

This branch has not been deployed

No deployments
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.

1 participant