How to hide the html body when using curl?











up vote
0
down vote

favorite












Currently I am experimenting with curl flags, looking how to get only the response headers, follow the redirection if any, encryption and authentication used and the round trip time.



What flag should I use to hide/disable the HTML body in the output?










share|improve this question




























    up vote
    0
    down vote

    favorite












    Currently I am experimenting with curl flags, looking how to get only the response headers, follow the redirection if any, encryption and authentication used and the round trip time.



    What flag should I use to hide/disable the HTML body in the output?










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Currently I am experimenting with curl flags, looking how to get only the response headers, follow the redirection if any, encryption and authentication used and the round trip time.



      What flag should I use to hide/disable the HTML body in the output?










      share|improve this question















      Currently I am experimenting with curl flags, looking how to get only the response headers, follow the redirection if any, encryption and authentication used and the round trip time.



      What flag should I use to hide/disable the HTML body in the output?







      https curl






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 25 at 17:31









      bertieb

      5,537112342




      5,537112342










      asked Feb 25 at 17:17







      user876358





























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          How to make curl disable html output



          Use the -s flag (for silent operation) and redirect stout (>) to (eg) /dev/null (or, if you're on Windows, simply NUL)



          This, inc combination with -D <file> (aka --dump-header) may give you the output you are looking for.



          The curl manpage has more information on the command-line options which may be helpful.



          Example



          $ curl -s https://superuser.com -D su.txt > /dev/null
          $ less -FX su.txt
          HTTP/2 200
          date: Sun, 25 Feb 2018 17:24:30 GMT
          content-type: text/html; charset=utf-8
          x-frame-options: SAMEORIGIN
          x-request-guid: e147da19-7cc9-42cd-8706-4204fd64d4a9
          strict-transport-security: max-age=15552000
          content-security-policy-report-only: default-src https: wss: data: blob: 'unsafe-eval' 'unsafe-inline'; report-uri https://stackoverflow.report-uri.io/r/default/csp/reportOnly
          accept-ranges: bytes
          via: 1.1 varnish
          x-served-by: cache-lcy19224-LCY
          x-cache: MISS
          x-cache-hits: 0
          x-timer: S1519579470.439587,VS0,VE88
          vary: Fastly-SSL
          x-dns-prefetch-control: off
          set-cookie: prov=d007391b-afc2-4717-282a-287f18827242; domain=.superuser.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
          cache-control: private
          content-length: 101543





          share|improve this answer























          • What about a Windows environment that uses git bash to curl ?
            – user876358
            Feb 25 at 17:42










          • Windows' equivalent to /dev/null is simply NUL; I assume git bash will respect that but cannot test at the minute. I have updated my answer to include that.
            – bertieb
            Feb 25 at 17:48








          • 1




            In addition, some quick searches indicates that git bash implements /dev/null, so /dev/null may work in that case!
            – bertieb
            Feb 25 at 17:50


















          up vote
          0
          down vote













          You can discard the body while still keeping the headers by telling curl to dump them on stdout:



          $ curl -D/dev/stdout -o/dev/null -s https://superuser.com
          HTTP/1.1 200 OK
          Cache-Control: private
          Content-Type: text/html; charset=utf-8
          X-Frame-Options: SAMEORIGIN
          X-Request-Guid: a599d44b-705c-4615-a8d8-80c7614bd64f
          ...




          • -D/dev/stdout: dump the headers on standard output


          • -o/dev/null: discard the body


          • -s: disable the progress meter






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1298244%2fhow-to-hide-the-html-body-when-using-curl%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown
























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            How to make curl disable html output



            Use the -s flag (for silent operation) and redirect stout (>) to (eg) /dev/null (or, if you're on Windows, simply NUL)



            This, inc combination with -D <file> (aka --dump-header) may give you the output you are looking for.



            The curl manpage has more information on the command-line options which may be helpful.



            Example



            $ curl -s https://superuser.com -D su.txt > /dev/null
            $ less -FX su.txt
            HTTP/2 200
            date: Sun, 25 Feb 2018 17:24:30 GMT
            content-type: text/html; charset=utf-8
            x-frame-options: SAMEORIGIN
            x-request-guid: e147da19-7cc9-42cd-8706-4204fd64d4a9
            strict-transport-security: max-age=15552000
            content-security-policy-report-only: default-src https: wss: data: blob: 'unsafe-eval' 'unsafe-inline'; report-uri https://stackoverflow.report-uri.io/r/default/csp/reportOnly
            accept-ranges: bytes
            via: 1.1 varnish
            x-served-by: cache-lcy19224-LCY
            x-cache: MISS
            x-cache-hits: 0
            x-timer: S1519579470.439587,VS0,VE88
            vary: Fastly-SSL
            x-dns-prefetch-control: off
            set-cookie: prov=d007391b-afc2-4717-282a-287f18827242; domain=.superuser.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
            cache-control: private
            content-length: 101543





            share|improve this answer























            • What about a Windows environment that uses git bash to curl ?
              – user876358
              Feb 25 at 17:42










            • Windows' equivalent to /dev/null is simply NUL; I assume git bash will respect that but cannot test at the minute. I have updated my answer to include that.
              – bertieb
              Feb 25 at 17:48








            • 1




              In addition, some quick searches indicates that git bash implements /dev/null, so /dev/null may work in that case!
              – bertieb
              Feb 25 at 17:50















            up vote
            2
            down vote













            How to make curl disable html output



            Use the -s flag (for silent operation) and redirect stout (>) to (eg) /dev/null (or, if you're on Windows, simply NUL)



            This, inc combination with -D <file> (aka --dump-header) may give you the output you are looking for.



            The curl manpage has more information on the command-line options which may be helpful.



            Example



            $ curl -s https://superuser.com -D su.txt > /dev/null
            $ less -FX su.txt
            HTTP/2 200
            date: Sun, 25 Feb 2018 17:24:30 GMT
            content-type: text/html; charset=utf-8
            x-frame-options: SAMEORIGIN
            x-request-guid: e147da19-7cc9-42cd-8706-4204fd64d4a9
            strict-transport-security: max-age=15552000
            content-security-policy-report-only: default-src https: wss: data: blob: 'unsafe-eval' 'unsafe-inline'; report-uri https://stackoverflow.report-uri.io/r/default/csp/reportOnly
            accept-ranges: bytes
            via: 1.1 varnish
            x-served-by: cache-lcy19224-LCY
            x-cache: MISS
            x-cache-hits: 0
            x-timer: S1519579470.439587,VS0,VE88
            vary: Fastly-SSL
            x-dns-prefetch-control: off
            set-cookie: prov=d007391b-afc2-4717-282a-287f18827242; domain=.superuser.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
            cache-control: private
            content-length: 101543





            share|improve this answer























            • What about a Windows environment that uses git bash to curl ?
              – user876358
              Feb 25 at 17:42










            • Windows' equivalent to /dev/null is simply NUL; I assume git bash will respect that but cannot test at the minute. I have updated my answer to include that.
              – bertieb
              Feb 25 at 17:48








            • 1




              In addition, some quick searches indicates that git bash implements /dev/null, so /dev/null may work in that case!
              – bertieb
              Feb 25 at 17:50













            up vote
            2
            down vote










            up vote
            2
            down vote









            How to make curl disable html output



            Use the -s flag (for silent operation) and redirect stout (>) to (eg) /dev/null (or, if you're on Windows, simply NUL)



            This, inc combination with -D <file> (aka --dump-header) may give you the output you are looking for.



            The curl manpage has more information on the command-line options which may be helpful.



            Example



            $ curl -s https://superuser.com -D su.txt > /dev/null
            $ less -FX su.txt
            HTTP/2 200
            date: Sun, 25 Feb 2018 17:24:30 GMT
            content-type: text/html; charset=utf-8
            x-frame-options: SAMEORIGIN
            x-request-guid: e147da19-7cc9-42cd-8706-4204fd64d4a9
            strict-transport-security: max-age=15552000
            content-security-policy-report-only: default-src https: wss: data: blob: 'unsafe-eval' 'unsafe-inline'; report-uri https://stackoverflow.report-uri.io/r/default/csp/reportOnly
            accept-ranges: bytes
            via: 1.1 varnish
            x-served-by: cache-lcy19224-LCY
            x-cache: MISS
            x-cache-hits: 0
            x-timer: S1519579470.439587,VS0,VE88
            vary: Fastly-SSL
            x-dns-prefetch-control: off
            set-cookie: prov=d007391b-afc2-4717-282a-287f18827242; domain=.superuser.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
            cache-control: private
            content-length: 101543





            share|improve this answer














            How to make curl disable html output



            Use the -s flag (for silent operation) and redirect stout (>) to (eg) /dev/null (or, if you're on Windows, simply NUL)



            This, inc combination with -D <file> (aka --dump-header) may give you the output you are looking for.



            The curl manpage has more information on the command-line options which may be helpful.



            Example



            $ curl -s https://superuser.com -D su.txt > /dev/null
            $ less -FX su.txt
            HTTP/2 200
            date: Sun, 25 Feb 2018 17:24:30 GMT
            content-type: text/html; charset=utf-8
            x-frame-options: SAMEORIGIN
            x-request-guid: e147da19-7cc9-42cd-8706-4204fd64d4a9
            strict-transport-security: max-age=15552000
            content-security-policy-report-only: default-src https: wss: data: blob: 'unsafe-eval' 'unsafe-inline'; report-uri https://stackoverflow.report-uri.io/r/default/csp/reportOnly
            accept-ranges: bytes
            via: 1.1 varnish
            x-served-by: cache-lcy19224-LCY
            x-cache: MISS
            x-cache-hits: 0
            x-timer: S1519579470.439587,VS0,VE88
            vary: Fastly-SSL
            x-dns-prefetch-control: off
            set-cookie: prov=d007391b-afc2-4717-282a-287f18827242; domain=.superuser.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly
            cache-control: private
            content-length: 101543






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 25 at 17:47

























            answered Feb 25 at 17:28









            bertieb

            5,537112342




            5,537112342












            • What about a Windows environment that uses git bash to curl ?
              – user876358
              Feb 25 at 17:42










            • Windows' equivalent to /dev/null is simply NUL; I assume git bash will respect that but cannot test at the minute. I have updated my answer to include that.
              – bertieb
              Feb 25 at 17:48








            • 1




              In addition, some quick searches indicates that git bash implements /dev/null, so /dev/null may work in that case!
              – bertieb
              Feb 25 at 17:50


















            • What about a Windows environment that uses git bash to curl ?
              – user876358
              Feb 25 at 17:42










            • Windows' equivalent to /dev/null is simply NUL; I assume git bash will respect that but cannot test at the minute. I have updated my answer to include that.
              – bertieb
              Feb 25 at 17:48








            • 1




              In addition, some quick searches indicates that git bash implements /dev/null, so /dev/null may work in that case!
              – bertieb
              Feb 25 at 17:50
















            What about a Windows environment that uses git bash to curl ?
            – user876358
            Feb 25 at 17:42




            What about a Windows environment that uses git bash to curl ?
            – user876358
            Feb 25 at 17:42












            Windows' equivalent to /dev/null is simply NUL; I assume git bash will respect that but cannot test at the minute. I have updated my answer to include that.
            – bertieb
            Feb 25 at 17:48






            Windows' equivalent to /dev/null is simply NUL; I assume git bash will respect that but cannot test at the minute. I have updated my answer to include that.
            – bertieb
            Feb 25 at 17:48






            1




            1




            In addition, some quick searches indicates that git bash implements /dev/null, so /dev/null may work in that case!
            – bertieb
            Feb 25 at 17:50




            In addition, some quick searches indicates that git bash implements /dev/null, so /dev/null may work in that case!
            – bertieb
            Feb 25 at 17:50












            up vote
            0
            down vote













            You can discard the body while still keeping the headers by telling curl to dump them on stdout:



            $ curl -D/dev/stdout -o/dev/null -s https://superuser.com
            HTTP/1.1 200 OK
            Cache-Control: private
            Content-Type: text/html; charset=utf-8
            X-Frame-Options: SAMEORIGIN
            X-Request-Guid: a599d44b-705c-4615-a8d8-80c7614bd64f
            ...




            • -D/dev/stdout: dump the headers on standard output


            • -o/dev/null: discard the body


            • -s: disable the progress meter






            share|improve this answer

























              up vote
              0
              down vote













              You can discard the body while still keeping the headers by telling curl to dump them on stdout:



              $ curl -D/dev/stdout -o/dev/null -s https://superuser.com
              HTTP/1.1 200 OK
              Cache-Control: private
              Content-Type: text/html; charset=utf-8
              X-Frame-Options: SAMEORIGIN
              X-Request-Guid: a599d44b-705c-4615-a8d8-80c7614bd64f
              ...




              • -D/dev/stdout: dump the headers on standard output


              • -o/dev/null: discard the body


              • -s: disable the progress meter






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                You can discard the body while still keeping the headers by telling curl to dump them on stdout:



                $ curl -D/dev/stdout -o/dev/null -s https://superuser.com
                HTTP/1.1 200 OK
                Cache-Control: private
                Content-Type: text/html; charset=utf-8
                X-Frame-Options: SAMEORIGIN
                X-Request-Guid: a599d44b-705c-4615-a8d8-80c7614bd64f
                ...




                • -D/dev/stdout: dump the headers on standard output


                • -o/dev/null: discard the body


                • -s: disable the progress meter






                share|improve this answer












                You can discard the body while still keeping the headers by telling curl to dump them on stdout:



                $ curl -D/dev/stdout -o/dev/null -s https://superuser.com
                HTTP/1.1 200 OK
                Cache-Control: private
                Content-Type: text/html; charset=utf-8
                X-Frame-Options: SAMEORIGIN
                X-Request-Guid: a599d44b-705c-4615-a8d8-80c7614bd64f
                ...




                • -D/dev/stdout: dump the headers on standard output


                • -o/dev/null: discard the body


                • -s: disable the progress meter







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 7 at 14:58









                bfontaine

                12410




                12410






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1298244%2fhow-to-hide-the-html-body-when-using-curl%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                    Mangá

                     ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕