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

curl_headers: Handle POST requests #19445

Open
wants to merge 2 commits into from

Conversation

samford
Copy link
Member

@samford samford commented Mar 8, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Livecheck::Strategy.page_headers uses Utils::Curl.curl_headers but the method only handles HEAD and GET requests. I recently added POST support to livecheck but forgot to update curl_headers in the process, so livecheck blocks using the HeaderMatch strategy along with post_form or post_json will fail because curl doesn't allow both --head and --data/--json arguments (e.g., Homebrew/homebrew-cask#204216).

This addresses the issue by updating curl_headers to handle POST requests and skip the GET retry logic.


The aforementioned effect-house PR also demonstrated that some servers will return an unexpected response if a Content-Length header isn't included in the POST request, so this adds the header to the post_args array when post_form or post_json are used.

samford added 2 commits March 7, 2025 20:28
`Livecheck::Strategy.page_headers` uses `Utils::Curl.curl_headers` but
the method only handles `HEAD` and `GET` requests. I recently added
`POST` support to livecheck but forgot to update `curl_headers` in the
process, so `livecheck` blocks using the `HeaderMatch` strategy along
with `post_form` or `post_json` will fail because curl doesn't allow
both `--head` and `--data`/`--json` arguments.

This addresses the issue by updating `curl_headers` to handle `POST`
requests and skip the `GET` retry logic.
Some servers will return an error response if a `Content-Length`
header isn't included in a `POST` request, so this adds it to the
`post_args` array when `post_form` or `post_json` are used.
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @samford!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Mar 9, 2025
Any commits made after this event will not be merged.
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