Skip to content

In a config file, headers are not handled the same as on the CLI (header not sent) #12409

@Jiehong

Description

@Jiehong

I did this

When using --config, and with the cli, I get different results.

Using the CLI

$ curl -v --request POST --header 'Authorization: Bearer xxxx' --url https://example.com

I get the following output:

*   Trying 93.184.216.34:443...
* Connected to example.com (93.184.216.34) port 443
(...)
> POST / HTTP/1.1
> Host: example.com
> User-Agent: curl/8.4.0
> Accept: */*
> Authorization: Bearer xxxx
>
(...)
< HTTP/1.1 200 OK

Using a config file

With the following config file named test.curl:

request = POST
header = Authorization: Bearer xxxx
url = https://example.com

And then running it:

$ curl -v --config test.curl
Warning: ./test.curl:2: warning: 'header' uses unquoted whitespace in the line
Warning: that may cause side-effects
*   Trying 93.184.216.34:443...
* Connected to example.com (93.184.216.34) port 443
(...)
> POST / HTTP/1.1
> Host: example.com
> User-Agent: curl/8.4.0
> Accept: */*
>
(...)
< HTTP/1.1 200 OK

I expected the following

Using the config file, I expected the exact same as the CLI output.

In particular, the Authorization header should be sent as described.

Note that changing the header line in the config file to:

header = 'Authorization: Bearer xxx'

Does not remove the curl warning, and still does not send that header.

By the way, I realise it should be better to just use oauth2-bearer instead of creating the header by hand, but I have the same issue with any other headers.

curl/libcurl version

curl 8.4.0 (aarch64-apple-darwin22.6.0) libcurl/8.4.0 (SecureTransport) OpenSSL/3.1.4 zlib/1.2.11 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.4 libssh2/1.11.0 nghttp2/1.58.0 librtmp/2.3 OpenLDAP/2.6.6
Release-Date: 2023-10-11
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd

operating system

Darwin my-name 22.6.0 Darwin Kernel Version 22.6.0: Thu Nov 2 07:43:25 PDT 2023; root:xnu-8796.141.3.701.17~6/RELEASE_ARM64_T6020 arm64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions