Manual HTTP(S) request











up vote
9
down vote

favorite
3












I am looking for a tool (possibly on Linux) that will allow me to make a manual HTTP or HTTPS request. By manual, I really mean it: I should be able to feed it a text file which looks like



POST /foo HTTP/1.1
Host: www.example.com
Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Content-Type: text/plain
Content-Length: 11

Hello world


and a destination URL (www.example.com/foo), and send the request to the URL. At most, it would be useful if the Content_Length header was automatically computed.



I would be able to write such a tool using some library like httplib in Python, but the very reason I need it is to do manual investigation when something goes wrong with such libraries.










share|improve this question


















  • 1




    https specific question: superuser.com/questions/346958/…
    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Oct 5 at 9:34

















up vote
9
down vote

favorite
3












I am looking for a tool (possibly on Linux) that will allow me to make a manual HTTP or HTTPS request. By manual, I really mean it: I should be able to feed it a text file which looks like



POST /foo HTTP/1.1
Host: www.example.com
Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Content-Type: text/plain
Content-Length: 11

Hello world


and a destination URL (www.example.com/foo), and send the request to the URL. At most, it would be useful if the Content_Length header was automatically computed.



I would be able to write such a tool using some library like httplib in Python, but the very reason I need it is to do manual investigation when something goes wrong with such libraries.










share|improve this question


















  • 1




    https specific question: superuser.com/questions/346958/…
    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Oct 5 at 9:34















up vote
9
down vote

favorite
3









up vote
9
down vote

favorite
3






3





I am looking for a tool (possibly on Linux) that will allow me to make a manual HTTP or HTTPS request. By manual, I really mean it: I should be able to feed it a text file which looks like



POST /foo HTTP/1.1
Host: www.example.com
Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Content-Type: text/plain
Content-Length: 11

Hello world


and a destination URL (www.example.com/foo), and send the request to the URL. At most, it would be useful if the Content_Length header was automatically computed.



I would be able to write such a tool using some library like httplib in Python, but the very reason I need it is to do manual investigation when something goes wrong with such libraries.










share|improve this question













I am looking for a tool (possibly on Linux) that will allow me to make a manual HTTP or HTTPS request. By manual, I really mean it: I should be able to feed it a text file which looks like



POST /foo HTTP/1.1
Host: www.example.com
Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Content-Type: text/plain
Content-Length: 11

Hello world


and a destination URL (www.example.com/foo), and send the request to the URL. At most, it would be useful if the Content_Length header was automatically computed.



I would be able to write such a tool using some library like httplib in Python, but the very reason I need it is to do manual investigation when something goes wrong with such libraries.







linux http https






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 18 '11 at 20:32









Andrea

435157




435157








  • 1




    https specific question: superuser.com/questions/346958/…
    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Oct 5 at 9:34
















  • 1




    https specific question: superuser.com/questions/346958/…
    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Oct 5 at 9:34










1




1




https specific question: superuser.com/questions/346958/…
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Oct 5 at 9:34






https specific question: superuser.com/questions/346958/…
– Ciro Santilli 新疆改造中心 六四事件 法轮功
Oct 5 at 9:34












5 Answers
5






active

oldest

votes

















up vote
9
down vote



accepted










wget has a --post-file option which should work for you.



Edit: Also, there's Ncat, which you would use in a similar fashion to Randolf Richardson's telnet suggestion, except that it also supports SSL/HTTPS:



ncat -C --ssl www.example.com 443 < input.txt > output.txt





share|improve this answer



















  • 5




    If you need HTTPS, use openssl instead of netcat: openssl s_client -connect <address>:443
    – Ambroz Bizjak
    Jul 18 '11 at 22:24












  • wget --post-file will add headers and use the specified file only for the body of the request.
    – David Balažic
    Apr 3 at 18:16


















up vote
6
down vote













For HTTP (not HTTPS), one alternative to the "wget" command that comes to mind is to use telnet as follows:




  • telnet hostname 80 < input.txt > output.txt


The file "input.txt" is your list of pre-set commands that you wish to feed to the host at hostname and the file "output.txt" will store the response.






share|improve this answer

















  • 1




    This made me wonder if netcat supports SSL, and lo-and-behold, there's Ncat, an SSL-enabled netcat clone.
    – Chris Acheson
    Jul 18 '11 at 22:15










  • @Chris Acheson (+1): That's fantastic! Please feel free to copy what I wrote in a separate answer and adapt it to a solution that utilizes NetCat (I'll vote for your answer if you do this).
    – Randolf Richardson
    Jul 18 '11 at 22:38


















up vote
1
down vote













You can issue a GET request with OpenSSL:



openssl s_client -quiet -connect cdn.sstatic.net:443 <<eof
GET /stackexchange/js/universal-login.js HTTP/1.1
Connection: close
Host: cdn.sstatic.net

eof


Note that you can also use "HTTP/2", but be careful because some servers
(e.g. github.com) do not support it.






share|improve this answer






























    up vote
    0
    down vote













    For me, it worked creating a request file (Example: request.txt)



    POST /foo HTTP/1.1
    Host: www.example.com
    Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    Accept-Language: en-gb,en;q=0.5
    Content-Type: text/plain; charset=utf-8
    Content-Length: 11
    Connection: close

    Hello world


    And then call the openssl s_client command:



    cat request.txt | openssl s_client -quiet -connect www.example.com:443



    However, be careful about some points:




    • The file must be encoded properly, specially the content body. Better if you include a header Content-type: text/plain; charset=utf-8 if the file is utf-8 encoded.

    • The line endings for the headers must be CR/LF. Only with LF the web server could return HTTP/1.1 505 HTTP Version Not Supported, because the standard HTTP protocol uses CR/LF for line endings (https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html). You can use the unix2dos command to do this conversion.

    • Add a Connection: close header to terminate the request and return from the call. Otherwise, the command will be awaiting for user interaction, if the server normally responds with a Connection: keep-alive header.






    share|improve this answer








    New contributor




    F.Igor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      up vote
      -1
      down vote













      I'm surprised no one mentioned cURL. It is made exactly for what you want to do. And it is available on practically any platform (including Windows).



      So for your example all you would do is:



      curl -H 'Content-Type: text/plain' -d 'Hello World' www.example.com


      Which captured from Wireshark will net you:



      POST / HTTP/1.1
      User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
      Host: www.example.com
      Accept: */*
      Content-Type: text/plain
      Content-Length: 11

      Hello world


      You can easily modify the headers further if you wish to do all kinds of stuff (i.e. change the user-agent, etc).



      Edit: Didn't notice the "from a file" requirement. You can do that too, either plain ascii or binary files. You just specify the filename with an @ symbol



      -d @/tmp/HelloWorldFile





      share|improve this answer























      • curl is almost what I want, but requires me to specify the headers on the command line, which is very impractical. I need something which allows me to specify the complete text of the request, including the method and the headers, from a file, and ncat does eaxctly what I want. Thank you anyway :-)
        – Andrea
        Jul 21 '11 at 9:05











      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',
      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%2f312094%2fmanual-https-request%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      9
      down vote



      accepted










      wget has a --post-file option which should work for you.



      Edit: Also, there's Ncat, which you would use in a similar fashion to Randolf Richardson's telnet suggestion, except that it also supports SSL/HTTPS:



      ncat -C --ssl www.example.com 443 < input.txt > output.txt





      share|improve this answer



















      • 5




        If you need HTTPS, use openssl instead of netcat: openssl s_client -connect <address>:443
        – Ambroz Bizjak
        Jul 18 '11 at 22:24












      • wget --post-file will add headers and use the specified file only for the body of the request.
        – David Balažic
        Apr 3 at 18:16















      up vote
      9
      down vote



      accepted










      wget has a --post-file option which should work for you.



      Edit: Also, there's Ncat, which you would use in a similar fashion to Randolf Richardson's telnet suggestion, except that it also supports SSL/HTTPS:



      ncat -C --ssl www.example.com 443 < input.txt > output.txt





      share|improve this answer



















      • 5




        If you need HTTPS, use openssl instead of netcat: openssl s_client -connect <address>:443
        – Ambroz Bizjak
        Jul 18 '11 at 22:24












      • wget --post-file will add headers and use the specified file only for the body of the request.
        – David Balažic
        Apr 3 at 18:16













      up vote
      9
      down vote



      accepted







      up vote
      9
      down vote



      accepted






      wget has a --post-file option which should work for you.



      Edit: Also, there's Ncat, which you would use in a similar fashion to Randolf Richardson's telnet suggestion, except that it also supports SSL/HTTPS:



      ncat -C --ssl www.example.com 443 < input.txt > output.txt





      share|improve this answer














      wget has a --post-file option which should work for you.



      Edit: Also, there's Ncat, which you would use in a similar fashion to Randolf Richardson's telnet suggestion, except that it also supports SSL/HTTPS:



      ncat -C --ssl www.example.com 443 < input.txt > output.txt






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jul 19 '11 at 4:15

























      answered Jul 18 '11 at 20:42









      Chris Acheson

      94976




      94976








      • 5




        If you need HTTPS, use openssl instead of netcat: openssl s_client -connect <address>:443
        – Ambroz Bizjak
        Jul 18 '11 at 22:24












      • wget --post-file will add headers and use the specified file only for the body of the request.
        – David Balažic
        Apr 3 at 18:16














      • 5




        If you need HTTPS, use openssl instead of netcat: openssl s_client -connect <address>:443
        – Ambroz Bizjak
        Jul 18 '11 at 22:24












      • wget --post-file will add headers and use the specified file only for the body of the request.
        – David Balažic
        Apr 3 at 18:16








      5




      5




      If you need HTTPS, use openssl instead of netcat: openssl s_client -connect <address>:443
      – Ambroz Bizjak
      Jul 18 '11 at 22:24






      If you need HTTPS, use openssl instead of netcat: openssl s_client -connect <address>:443
      – Ambroz Bizjak
      Jul 18 '11 at 22:24














      wget --post-file will add headers and use the specified file only for the body of the request.
      – David Balažic
      Apr 3 at 18:16




      wget --post-file will add headers and use the specified file only for the body of the request.
      – David Balažic
      Apr 3 at 18:16












      up vote
      6
      down vote













      For HTTP (not HTTPS), one alternative to the "wget" command that comes to mind is to use telnet as follows:




      • telnet hostname 80 < input.txt > output.txt


      The file "input.txt" is your list of pre-set commands that you wish to feed to the host at hostname and the file "output.txt" will store the response.






      share|improve this answer

















      • 1




        This made me wonder if netcat supports SSL, and lo-and-behold, there's Ncat, an SSL-enabled netcat clone.
        – Chris Acheson
        Jul 18 '11 at 22:15










      • @Chris Acheson (+1): That's fantastic! Please feel free to copy what I wrote in a separate answer and adapt it to a solution that utilizes NetCat (I'll vote for your answer if you do this).
        – Randolf Richardson
        Jul 18 '11 at 22:38















      up vote
      6
      down vote













      For HTTP (not HTTPS), one alternative to the "wget" command that comes to mind is to use telnet as follows:




      • telnet hostname 80 < input.txt > output.txt


      The file "input.txt" is your list of pre-set commands that you wish to feed to the host at hostname and the file "output.txt" will store the response.






      share|improve this answer

















      • 1




        This made me wonder if netcat supports SSL, and lo-and-behold, there's Ncat, an SSL-enabled netcat clone.
        – Chris Acheson
        Jul 18 '11 at 22:15










      • @Chris Acheson (+1): That's fantastic! Please feel free to copy what I wrote in a separate answer and adapt it to a solution that utilizes NetCat (I'll vote for your answer if you do this).
        – Randolf Richardson
        Jul 18 '11 at 22:38













      up vote
      6
      down vote










      up vote
      6
      down vote









      For HTTP (not HTTPS), one alternative to the "wget" command that comes to mind is to use telnet as follows:




      • telnet hostname 80 < input.txt > output.txt


      The file "input.txt" is your list of pre-set commands that you wish to feed to the host at hostname and the file "output.txt" will store the response.






      share|improve this answer












      For HTTP (not HTTPS), one alternative to the "wget" command that comes to mind is to use telnet as follows:




      • telnet hostname 80 < input.txt > output.txt


      The file "input.txt" is your list of pre-set commands that you wish to feed to the host at hostname and the file "output.txt" will store the response.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jul 18 '11 at 20:54









      Randolf Richardson

      13.4k2850




      13.4k2850








      • 1




        This made me wonder if netcat supports SSL, and lo-and-behold, there's Ncat, an SSL-enabled netcat clone.
        – Chris Acheson
        Jul 18 '11 at 22:15










      • @Chris Acheson (+1): That's fantastic! Please feel free to copy what I wrote in a separate answer and adapt it to a solution that utilizes NetCat (I'll vote for your answer if you do this).
        – Randolf Richardson
        Jul 18 '11 at 22:38














      • 1




        This made me wonder if netcat supports SSL, and lo-and-behold, there's Ncat, an SSL-enabled netcat clone.
        – Chris Acheson
        Jul 18 '11 at 22:15










      • @Chris Acheson (+1): That's fantastic! Please feel free to copy what I wrote in a separate answer and adapt it to a solution that utilizes NetCat (I'll vote for your answer if you do this).
        – Randolf Richardson
        Jul 18 '11 at 22:38








      1




      1




      This made me wonder if netcat supports SSL, and lo-and-behold, there's Ncat, an SSL-enabled netcat clone.
      – Chris Acheson
      Jul 18 '11 at 22:15




      This made me wonder if netcat supports SSL, and lo-and-behold, there's Ncat, an SSL-enabled netcat clone.
      – Chris Acheson
      Jul 18 '11 at 22:15












      @Chris Acheson (+1): That's fantastic! Please feel free to copy what I wrote in a separate answer and adapt it to a solution that utilizes NetCat (I'll vote for your answer if you do this).
      – Randolf Richardson
      Jul 18 '11 at 22:38




      @Chris Acheson (+1): That's fantastic! Please feel free to copy what I wrote in a separate answer and adapt it to a solution that utilizes NetCat (I'll vote for your answer if you do this).
      – Randolf Richardson
      Jul 18 '11 at 22:38










      up vote
      1
      down vote













      You can issue a GET request with OpenSSL:



      openssl s_client -quiet -connect cdn.sstatic.net:443 <<eof
      GET /stackexchange/js/universal-login.js HTTP/1.1
      Connection: close
      Host: cdn.sstatic.net

      eof


      Note that you can also use "HTTP/2", but be careful because some servers
      (e.g. github.com) do not support it.






      share|improve this answer



























        up vote
        1
        down vote













        You can issue a GET request with OpenSSL:



        openssl s_client -quiet -connect cdn.sstatic.net:443 <<eof
        GET /stackexchange/js/universal-login.js HTTP/1.1
        Connection: close
        Host: cdn.sstatic.net

        eof


        Note that you can also use "HTTP/2", but be careful because some servers
        (e.g. github.com) do not support it.






        share|improve this answer

























          up vote
          1
          down vote










          up vote
          1
          down vote









          You can issue a GET request with OpenSSL:



          openssl s_client -quiet -connect cdn.sstatic.net:443 <<eof
          GET /stackexchange/js/universal-login.js HTTP/1.1
          Connection: close
          Host: cdn.sstatic.net

          eof


          Note that you can also use "HTTP/2", but be careful because some servers
          (e.g. github.com) do not support it.






          share|improve this answer














          You can issue a GET request with OpenSSL:



          openssl s_client -quiet -connect cdn.sstatic.net:443 <<eof
          GET /stackexchange/js/universal-login.js HTTP/1.1
          Connection: close
          Host: cdn.sstatic.net

          eof


          Note that you can also use "HTTP/2", but be careful because some servers
          (e.g. github.com) do not support it.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 1 at 19:38

























          answered Jan 22 at 5:04









          Steven Penny

          4,1101683133




          4,1101683133






















              up vote
              0
              down vote













              For me, it worked creating a request file (Example: request.txt)



              POST /foo HTTP/1.1
              Host: www.example.com
              Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
              Accept-Language: en-gb,en;q=0.5
              Content-Type: text/plain; charset=utf-8
              Content-Length: 11
              Connection: close

              Hello world


              And then call the openssl s_client command:



              cat request.txt | openssl s_client -quiet -connect www.example.com:443



              However, be careful about some points:




              • The file must be encoded properly, specially the content body. Better if you include a header Content-type: text/plain; charset=utf-8 if the file is utf-8 encoded.

              • The line endings for the headers must be CR/LF. Only with LF the web server could return HTTP/1.1 505 HTTP Version Not Supported, because the standard HTTP protocol uses CR/LF for line endings (https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html). You can use the unix2dos command to do this conversion.

              • Add a Connection: close header to terminate the request and return from the call. Otherwise, the command will be awaiting for user interaction, if the server normally responds with a Connection: keep-alive header.






              share|improve this answer








              New contributor




              F.Igor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






















                up vote
                0
                down vote













                For me, it worked creating a request file (Example: request.txt)



                POST /foo HTTP/1.1
                Host: www.example.com
                Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
                Accept-Language: en-gb,en;q=0.5
                Content-Type: text/plain; charset=utf-8
                Content-Length: 11
                Connection: close

                Hello world


                And then call the openssl s_client command:



                cat request.txt | openssl s_client -quiet -connect www.example.com:443



                However, be careful about some points:




                • The file must be encoded properly, specially the content body. Better if you include a header Content-type: text/plain; charset=utf-8 if the file is utf-8 encoded.

                • The line endings for the headers must be CR/LF. Only with LF the web server could return HTTP/1.1 505 HTTP Version Not Supported, because the standard HTTP protocol uses CR/LF for line endings (https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html). You can use the unix2dos command to do this conversion.

                • Add a Connection: close header to terminate the request and return from the call. Otherwise, the command will be awaiting for user interaction, if the server normally responds with a Connection: keep-alive header.






                share|improve this answer








                New contributor




                F.Igor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.




















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  For me, it worked creating a request file (Example: request.txt)



                  POST /foo HTTP/1.1
                  Host: www.example.com
                  Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
                  Accept-Language: en-gb,en;q=0.5
                  Content-Type: text/plain; charset=utf-8
                  Content-Length: 11
                  Connection: close

                  Hello world


                  And then call the openssl s_client command:



                  cat request.txt | openssl s_client -quiet -connect www.example.com:443



                  However, be careful about some points:




                  • The file must be encoded properly, specially the content body. Better if you include a header Content-type: text/plain; charset=utf-8 if the file is utf-8 encoded.

                  • The line endings for the headers must be CR/LF. Only with LF the web server could return HTTP/1.1 505 HTTP Version Not Supported, because the standard HTTP protocol uses CR/LF for line endings (https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html). You can use the unix2dos command to do this conversion.

                  • Add a Connection: close header to terminate the request and return from the call. Otherwise, the command will be awaiting for user interaction, if the server normally responds with a Connection: keep-alive header.






                  share|improve this answer








                  New contributor




                  F.Igor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  For me, it worked creating a request file (Example: request.txt)



                  POST /foo HTTP/1.1
                  Host: www.example.com
                  Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
                  Accept-Language: en-gb,en;q=0.5
                  Content-Type: text/plain; charset=utf-8
                  Content-Length: 11
                  Connection: close

                  Hello world


                  And then call the openssl s_client command:



                  cat request.txt | openssl s_client -quiet -connect www.example.com:443



                  However, be careful about some points:




                  • The file must be encoded properly, specially the content body. Better if you include a header Content-type: text/plain; charset=utf-8 if the file is utf-8 encoded.

                  • The line endings for the headers must be CR/LF. Only with LF the web server could return HTTP/1.1 505 HTTP Version Not Supported, because the standard HTTP protocol uses CR/LF for line endings (https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html). You can use the unix2dos command to do this conversion.

                  • Add a Connection: close header to terminate the request and return from the call. Otherwise, the command will be awaiting for user interaction, if the server normally responds with a Connection: keep-alive header.







                  share|improve this answer








                  New contributor




                  F.Igor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  F.Igor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered 21 hours ago









                  F.Igor

                  1011




                  1011




                  New contributor




                  F.Igor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  F.Igor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  F.Igor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






















                      up vote
                      -1
                      down vote













                      I'm surprised no one mentioned cURL. It is made exactly for what you want to do. And it is available on practically any platform (including Windows).



                      So for your example all you would do is:



                      curl -H 'Content-Type: text/plain' -d 'Hello World' www.example.com


                      Which captured from Wireshark will net you:



                      POST / HTTP/1.1
                      User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
                      Host: www.example.com
                      Accept: */*
                      Content-Type: text/plain
                      Content-Length: 11

                      Hello world


                      You can easily modify the headers further if you wish to do all kinds of stuff (i.e. change the user-agent, etc).



                      Edit: Didn't notice the "from a file" requirement. You can do that too, either plain ascii or binary files. You just specify the filename with an @ symbol



                      -d @/tmp/HelloWorldFile





                      share|improve this answer























                      • curl is almost what I want, but requires me to specify the headers on the command line, which is very impractical. I need something which allows me to specify the complete text of the request, including the method and the headers, from a file, and ncat does eaxctly what I want. Thank you anyway :-)
                        – Andrea
                        Jul 21 '11 at 9:05















                      up vote
                      -1
                      down vote













                      I'm surprised no one mentioned cURL. It is made exactly for what you want to do. And it is available on practically any platform (including Windows).



                      So for your example all you would do is:



                      curl -H 'Content-Type: text/plain' -d 'Hello World' www.example.com


                      Which captured from Wireshark will net you:



                      POST / HTTP/1.1
                      User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
                      Host: www.example.com
                      Accept: */*
                      Content-Type: text/plain
                      Content-Length: 11

                      Hello world


                      You can easily modify the headers further if you wish to do all kinds of stuff (i.e. change the user-agent, etc).



                      Edit: Didn't notice the "from a file" requirement. You can do that too, either plain ascii or binary files. You just specify the filename with an @ symbol



                      -d @/tmp/HelloWorldFile





                      share|improve this answer























                      • curl is almost what I want, but requires me to specify the headers on the command line, which is very impractical. I need something which allows me to specify the complete text of the request, including the method and the headers, from a file, and ncat does eaxctly what I want. Thank you anyway :-)
                        – Andrea
                        Jul 21 '11 at 9:05













                      up vote
                      -1
                      down vote










                      up vote
                      -1
                      down vote









                      I'm surprised no one mentioned cURL. It is made exactly for what you want to do. And it is available on practically any platform (including Windows).



                      So for your example all you would do is:



                      curl -H 'Content-Type: text/plain' -d 'Hello World' www.example.com


                      Which captured from Wireshark will net you:



                      POST / HTTP/1.1
                      User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
                      Host: www.example.com
                      Accept: */*
                      Content-Type: text/plain
                      Content-Length: 11

                      Hello world


                      You can easily modify the headers further if you wish to do all kinds of stuff (i.e. change the user-agent, etc).



                      Edit: Didn't notice the "from a file" requirement. You can do that too, either plain ascii or binary files. You just specify the filename with an @ symbol



                      -d @/tmp/HelloWorldFile





                      share|improve this answer














                      I'm surprised no one mentioned cURL. It is made exactly for what you want to do. And it is available on practically any platform (including Windows).



                      So for your example all you would do is:



                      curl -H 'Content-Type: text/plain' -d 'Hello World' www.example.com


                      Which captured from Wireshark will net you:



                      POST / HTTP/1.1
                      User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
                      Host: www.example.com
                      Accept: */*
                      Content-Type: text/plain
                      Content-Length: 11

                      Hello world


                      You can easily modify the headers further if you wish to do all kinds of stuff (i.e. change the user-agent, etc).



                      Edit: Didn't notice the "from a file" requirement. You can do that too, either plain ascii or binary files. You just specify the filename with an @ symbol



                      -d @/tmp/HelloWorldFile






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jul 20 '11 at 20:57

























                      answered Jul 20 '11 at 20:46









                      Nicholi

                      593411




                      593411












                      • curl is almost what I want, but requires me to specify the headers on the command line, which is very impractical. I need something which allows me to specify the complete text of the request, including the method and the headers, from a file, and ncat does eaxctly what I want. Thank you anyway :-)
                        – Andrea
                        Jul 21 '11 at 9:05


















                      • curl is almost what I want, but requires me to specify the headers on the command line, which is very impractical. I need something which allows me to specify the complete text of the request, including the method and the headers, from a file, and ncat does eaxctly what I want. Thank you anyway :-)
                        – Andrea
                        Jul 21 '11 at 9:05
















                      curl is almost what I want, but requires me to specify the headers on the command line, which is very impractical. I need something which allows me to specify the complete text of the request, including the method and the headers, from a file, and ncat does eaxctly what I want. Thank you anyway :-)
                      – Andrea
                      Jul 21 '11 at 9:05




                      curl is almost what I want, but requires me to specify the headers on the command line, which is very impractical. I need something which allows me to specify the complete text of the request, including the method and the headers, from a file, and ncat does eaxctly what I want. Thank you anyway :-)
                      – Andrea
                      Jul 21 '11 at 9:05


















                      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%2f312094%2fmanual-https-request%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

                      Probability when a professor distributes a quiz and homework assignment to a class of n students.

                      Aardman Animations

                      Are they similar matrix