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

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this question























    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.







    share|improve this question





















      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.







      share|improve this question











      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.









      share|improve this question










      share|improve this question




      share|improve this question









      asked May 2 at 16:30









      kenorb

      7,37636397




      7,37636397




















          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 @filename style, 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"





          share|improve this answer























            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            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






























            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 @filename style, 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"





            share|improve this answer



























              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 @filename style, 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"





              share|improve this answer

























                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 @filename style, 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"





                share|improve this answer















                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 @filename style, 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"






                share|improve this answer















                share|improve this answer



                share|improve this answer








                edited May 3 at 15:40


























                answered May 2 at 16:39









                kenorb

                7,37636397




                7,37636397






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    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













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay