Skip to content

header api: add curl_easy_header and curl_easy_nextheader #8593

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

Closed
wants to merge 9 commits into from

Conversation

bagder
Copy link
Member

@bagder bagder commented Mar 14, 2022

Early docs: https://github.com/curl/curl/wiki/get-headers-v2

  • code for the two functions
  • man pages for the functions
  • example showing the API functions in use
  • add test case for curl_easy_header
  • figure out how to deal with CONNECT response headers
  • figure out how to deal with 1xx response headers
  • add test case for curl_easy_header with CONNECT
  • documented as EXPERIMENTAL
  • add test case for curl_easy_header with 1xx
  • add test case for curl_easy_header with trailers
  • add test case for curl_easy_header in a redirect case
  • test case for curl_easy_nextheader
  • make it build fine when HTTP support is disabled
  • use a single malloc per stored header
  • make the function calls able to access headers from multiple responses from the transfer
  • allow curl -w to output header contents with %header{name}
  • supports -w %{header_json} - ouputs all headers as JSON
  • make -w %{header_json} handle duplicate headers
  • add test case for -w %header{name}
  • add test case for -w %{header_json}
  • support/handle psuedo headers
  • skip making a test for psuedo headers (due to lacking test infra)
  • make the API (and -w options) build opt-in while EXPERIMENTAL
  • make the tests run only if the headers API is enabled in the build
  • make sure the docs appear nicely on the website (pending PR)

Remove the wiki page (to keep the docs in a single place) after initial merge

Sorry, something went wrong.

@jay
Copy link
Member

jay commented Mar 14, 2022

does this cover 100 status responses, for example

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade

@bagder

This comment was marked as resolved.

@bagder

This comment was marked as resolved.

@bagder

This comment was marked as outdated.

@bagder bagder force-pushed the bagder/header-api branch 3 times, most recently from 1f8b020 to ebdd863 Compare March 15, 2022 22:23
@bagder bagder force-pushed the bagder/header-api branch from ebdd863 to 6be0394 Compare March 16, 2022 09:13
bagder added a commit that referenced this pull request Mar 16, 2022

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
Closes #8593
@bagder bagder force-pushed the bagder/header-api branch from 987e927 to 20abea3 Compare March 16, 2022 13:37
@bagder

This comment was marked as resolved.

bagder added a commit that referenced this pull request Mar 17, 2022

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
Add test 1940 to 1946 to verify.

Closes #8593
@bagder bagder force-pushed the bagder/header-api branch from f718fa2 to 29dd2fb Compare March 17, 2022 09:21
bagder added a commit that referenced this pull request Mar 18, 2022

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
Add test 1940 to 1946 to verify.

Closes #8593
@bagder bagder force-pushed the bagder/header-api branch from ba45097 to 0812db0 Compare March 18, 2022 12:01
@bagder bagder force-pushed the bagder/header-api branch from c135fdb to 0aa07f9 Compare March 19, 2022 14:57
bagder added a commit that referenced this pull request Mar 19, 2022

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
Add test 1940 to 1946 to verify.

Closes #8593
@bagder bagder force-pushed the bagder/header-api branch from 0aa07f9 to 53e022b Compare March 19, 2022 21:48
@bagder bagder marked this pull request as ready for review March 19, 2022 21:52
@bagder
Copy link
Member Author

bagder commented Mar 20, 2022

I'm ready to merge this within the next few days. Any comments to take into account before that happens?

bagder added 5 commits March 21, 2022 17:34

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
Add test 1940 to 1946 to verify.

Closes #8593

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
Outputs the response header 'name'

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
Outputs all response headers as a JSON object.

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
bagder added 4 commits March 21, 2022 17:35

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
Defaults to disabled while labeled EXPERIMENTAL.

Make all the headers API tests require 'headers-api' to run.

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
@bagder bagder force-pushed the bagder/header-api branch from 5f82d65 to d3d8949 Compare March 21, 2022 16:39
@bagder bagder closed this in d1e4a67 Mar 22, 2022
@bagder bagder deleted the bagder/header-api branch March 22, 2022 07:27
@nanonyme
Copy link

Hmm, was this supposed to hide the new experimental ABI by default if --enable-headers-api is not given? Because it doesn't seem it does.

@bagder
Copy link
Member Author

bagder commented Apr 28, 2022

Can you clarify what you're asking?

@nanonyme
Copy link

nanonyme commented Apr 28, 2022

This post clearly states that these new functions should not be exposed as they are experimental. Yet it looks based on our ABI checks that they are indeed exposed by default even without the flag to expose them https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/jobs/2386983527 Is this intended behaviour or should I file a bug?

@bagder
Copy link
Member Author

bagder commented Apr 28, 2022

The functions are present even when disabled, but they don't do anything. They have no functionality.

@nanonyme
Copy link

I see. But just exposing them means people may call them. As it was said, the ABI is subject to change up to function signatures so isn't it completely unsafe to keep them there even as no-op functions?

@bagder
Copy link
Member Author

bagder commented Apr 28, 2022

Why would someone call them if they don't do anything? And yes, providing experimental features risks that users don't read our warnings and go ahead and use them anyway. I don't see an easy way to prevent that.

@nanonyme
Copy link

Couldn't you just use USE_HEADERS_API macro to hide them as private symbols?

@dfandrich
Copy link
Contributor

dfandrich commented Apr 28, 2022 via email

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

Successfully merging this pull request may close these issues.

None yet

4 participants