How Do You Properly Set and Manage curl Headers in Your Requests? or What Are the Best Practices for

14 Replies, 1946 Views

Headers not working? Could be a redirect issue. curl doesn’t always forward headers on redirects unless you use `--location-trusted`. Try that if you’re hitting 3xx responses.

For multiple curl headers, I just break the command into lines with `\`:
```
curl -X POST \
-H "Content-Type: application/json" \
-H "Cache-Control: no-cache" \
https://example.com
```
Way easier to read.

And yeah, header case *shouldn’t* matter, but some legacy systems are weird.

Messages In This Thread



Users browsing this thread: 1 Guest(s)