Repository navigation
Setting and Inspecting Headers
SetHeaders configures custom HTTP headers for the outgoing request. It accepts two input forms:
Header names as keys, values as strings:
intentHeaders := Map(
"Authorization", "Bearer abc123",
"Content-Type", "application/json",
"X-Custom-Header", "3"
)
curl.SetHeaders(intentHeaders)Pre-formatted "Header: value" strings:
intentHeaders := [
"Authorization: Bearer abc123",
"Content-Type: application/json",
"X-Custom-Header: 3"
]
curl.SetHeaders(intentHeaders)| Value | Effect | Example |
|---|---|---|
"" (empty string) |
Disables an internally-used header |
Map("Proxy-Connection", "") or ["Proxy-Connection"]
|
";" (semicolon) |
Adds the header with no value. |
Map("Expect", ";") or ["Expect;"]
|
GetLastHeaders() returns the headers from the most recent transfer as text. See Download Modes for the full encoding and sentinel parameter reference.
curl.SetOpt("URL", "https://httpbin.org/headers")
curl.HeaderToMem()
curl.WriteToMem()
curl.Sync()
headers := curl.GetLastHeaders()
MsgBox headersInspectHeader returns the value of a named header from a specific connection in the transfer chain. This is most useful when redirects are involved, since each hop produces its own set of headers.
curl.SetOpt("URL", "https://httpbin.org/redirect-to?url=https%3A%2F%2Farchive.today")
curl.WriteToMem()
curl.Sync()
; Final connection (default, usually what you want)
finalDate := curl.InspectHeader("date")
; Initial connection (request index 0)
initialDate := curl.InspectHeader("date", , , 0)The request parameter (fourth slot) targets a specific hop in the redirect chain. 0 is the first connection. Omitting it returns the last.
GetAllHeaders returns a complete array of every header received across all redirect hops. Use it when you need to iterate over the full set rather than targeting one by name.
curl.SetOpt("URL", "https://httpbin.org/redirect-to?url=https%3A%2F%2Farchive.today")
curl.WriteToMem()
curl.Sync()
redirectCount := curl.GetInfo("REDIRECT_COUNT")
allHeaders := curl.GetAllHeaders()
MsgBox "Redirects: " redirectCount "`n`n"
. curl.PrintObj(allHeaders)The returned array has one entry per redirect hop (including the final destination). Each entry is an array of header objects.
- POST and Upload — sending data with headers
- Easy Handle Reference — full method list
Foundations
Operations
- Download Modes
- Setting and Listing Options
- Setting and Inspecting Headers
- POST and Upload
- Multiple Easy Handles
- Async and Multi Interface
- URL Construction
- Share Interface
- MIME and Multipart
- Raw Send and Receive
- Pause and Resume
- WebSocket
- SSL Sessions
- Debug and Diagnostics
API Reference
- Easy Handle Reference
- Multi Handle Reference
- Share Handle Reference
- MIME Handle Reference
- URL Handle Reference
- Utility Methods Reference
- WebSocket Reference
Code Snippets