How to pass header from stdin or local file into remote curl?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
The following curl command works as expected:
$ curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
* Rebuilt URL to: http://www.example.com/
...
> Accept: */*
> Foo:Bar
>
< HTTP/1.1 200 OK
...
since I can see my custom header (Foo:Bar), but it doesn't work when running via ssh:
$ ssh user@localhost curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
* Rebuilt URL to: http://www.example.com/
...
> Accept: */*
>
< HTTP/1.1 200 OK
...
I can confirm that the stdin works on the remote by:
$ ssh user@localhost cat <<<"Foo:Bar"
Foo:Bar
My goal is to pass the headers from stdin or local file (not from the variable) into remote curl.
And I'm not quite sure why the above doesn't work.
ssh curl stdin
add a comment |Â
up vote
0
down vote
favorite
The following curl command works as expected:
$ curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
* Rebuilt URL to: http://www.example.com/
...
> Accept: */*
> Foo:Bar
>
< HTTP/1.1 200 OK
...
since I can see my custom header (Foo:Bar), but it doesn't work when running via ssh:
$ ssh user@localhost curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
* Rebuilt URL to: http://www.example.com/
...
> Accept: */*
>
< HTTP/1.1 200 OK
...
I can confirm that the stdin works on the remote by:
$ ssh user@localhost cat <<<"Foo:Bar"
Foo:Bar
My goal is to pass the headers from stdin or local file (not from the variable) into remote curl.
And I'm not quite sure why the above doesn't work.
ssh curl stdin
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The following curl command works as expected:
$ curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
* Rebuilt URL to: http://www.example.com/
...
> Accept: */*
> Foo:Bar
>
< HTTP/1.1 200 OK
...
since I can see my custom header (Foo:Bar), but it doesn't work when running via ssh:
$ ssh user@localhost curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
* Rebuilt URL to: http://www.example.com/
...
> Accept: */*
>
< HTTP/1.1 200 OK
...
I can confirm that the stdin works on the remote by:
$ ssh user@localhost cat <<<"Foo:Bar"
Foo:Bar
My goal is to pass the headers from stdin or local file (not from the variable) into remote curl.
And I'm not quite sure why the above doesn't work.
ssh curl stdin
The following curl command works as expected:
$ curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
* Rebuilt URL to: http://www.example.com/
...
> Accept: */*
> Foo:Bar
>
< HTTP/1.1 200 OK
...
since I can see my custom header (Foo:Bar), but it doesn't work when running via ssh:
$ ssh user@localhost curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
* Rebuilt URL to: http://www.example.com/
...
> Accept: */*
>
< HTTP/1.1 200 OK
...
I can confirm that the stdin works on the remote by:
$ ssh user@localhost cat <<<"Foo:Bar"
Foo:Bar
My goal is to pass the headers from stdin or local file (not from the variable) into remote curl.
And I'm not quite sure why the above doesn't work.
ssh curl stdin
asked May 2 at 16:30
kenorb
7,37636397
7,37636397
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
The argument in @filename style for -H has been added in 7.55.0 (man curl).
-H/--header <header/@file>
Starting in 7.55.0, this option can take an argument in
@filenamestyle, which then adds a header for each line in the input file. Using@-will make curl read the header file from stdin.
The problem with ssh happened because older curl version was used.
So basically two different versions of curl were involved.
$ which curl && curl --version
/usr/local/bin/curl
curl 7.59.0 (x86_64-apple-darwin17.3.0) libcurl/7.59.0 OpenSSL/1.0.2o zlib/1.2.11 libidn2/2.0.4
$ ssh user@localhost 'which curl && curl --version'
/usr/bin/curl
curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
So hardcoding the path to newer /usr/local/bin/curl (v7.59/OpenSSL) it seems to work fine:
$ ssh user@localhost /usr/local/bin/curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The argument in @filename style for -H has been added in 7.55.0 (man curl).
-H/--header <header/@file>
Starting in 7.55.0, this option can take an argument in
@filenamestyle, which then adds a header for each line in the input file. Using@-will make curl read the header file from stdin.
The problem with ssh happened because older curl version was used.
So basically two different versions of curl were involved.
$ which curl && curl --version
/usr/local/bin/curl
curl 7.59.0 (x86_64-apple-darwin17.3.0) libcurl/7.59.0 OpenSSL/1.0.2o zlib/1.2.11 libidn2/2.0.4
$ ssh user@localhost 'which curl && curl --version'
/usr/bin/curl
curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
So hardcoding the path to newer /usr/local/bin/curl (v7.59/OpenSSL) it seems to work fine:
$ ssh user@localhost /usr/local/bin/curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
add a comment |Â
up vote
0
down vote
The argument in @filename style for -H has been added in 7.55.0 (man curl).
-H/--header <header/@file>
Starting in 7.55.0, this option can take an argument in
@filenamestyle, which then adds a header for each line in the input file. Using@-will make curl read the header file from stdin.
The problem with ssh happened because older curl version was used.
So basically two different versions of curl were involved.
$ which curl && curl --version
/usr/local/bin/curl
curl 7.59.0 (x86_64-apple-darwin17.3.0) libcurl/7.59.0 OpenSSL/1.0.2o zlib/1.2.11 libidn2/2.0.4
$ ssh user@localhost 'which curl && curl --version'
/usr/bin/curl
curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
So hardcoding the path to newer /usr/local/bin/curl (v7.59/OpenSSL) it seems to work fine:
$ ssh user@localhost /usr/local/bin/curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The argument in @filename style for -H has been added in 7.55.0 (man curl).
-H/--header <header/@file>
Starting in 7.55.0, this option can take an argument in
@filenamestyle, which then adds a header for each line in the input file. Using@-will make curl read the header file from stdin.
The problem with ssh happened because older curl version was used.
So basically two different versions of curl were involved.
$ which curl && curl --version
/usr/local/bin/curl
curl 7.59.0 (x86_64-apple-darwin17.3.0) libcurl/7.59.0 OpenSSL/1.0.2o zlib/1.2.11 libidn2/2.0.4
$ ssh user@localhost 'which curl && curl --version'
/usr/bin/curl
curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
So hardcoding the path to newer /usr/local/bin/curl (v7.59/OpenSSL) it seems to work fine:
$ ssh user@localhost /usr/local/bin/curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
The argument in @filename style for -H has been added in 7.55.0 (man curl).
-H/--header <header/@file>
Starting in 7.55.0, this option can take an argument in
@filenamestyle, which then adds a header for each line in the input file. Using@-will make curl read the header file from stdin.
The problem with ssh happened because older curl version was used.
So basically two different versions of curl were involved.
$ which curl && curl --version
/usr/local/bin/curl
curl 7.59.0 (x86_64-apple-darwin17.3.0) libcurl/7.59.0 OpenSSL/1.0.2o zlib/1.2.11 libidn2/2.0.4
$ ssh user@localhost 'which curl && curl --version'
/usr/bin/curl
curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
So hardcoding the path to newer /usr/local/bin/curl (v7.59/OpenSSL) it seems to work fine:
$ ssh user@localhost /usr/local/bin/curl -H @- -vso/dev/null http://www.example.com <<<"Foo:Bar"
edited May 3 at 15:40
answered May 2 at 16:39
kenorb
7,37636397
7,37636397
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441359%2fhow-to-pass-header-from-stdin-or-local-file-into-remote-curl%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password