What is the easiest way to set up a HTTP request logger

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












What is the easiest way to set up something locally to listen for GET requests on a custom port?



So that I could do curl -X GET -i 'localhost:34331/hello'



And verify that the request was received and inspect the request to look at the headers if any were sent and the URL that was used for the request







share|improve this question

























    up vote
    1
    down vote

    favorite












    What is the easiest way to set up something locally to listen for GET requests on a custom port?



    So that I could do curl -X GET -i 'localhost:34331/hello'



    And verify that the request was received and inspect the request to look at the headers if any were sent and the URL that was used for the request







    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      What is the easiest way to set up something locally to listen for GET requests on a custom port?



      So that I could do curl -X GET -i 'localhost:34331/hello'



      And verify that the request was received and inspect the request to look at the headers if any were sent and the URL that was used for the request







      share|improve this question













      What is the easiest way to set up something locally to listen for GET requests on a custom port?



      So that I could do curl -X GET -i 'localhost:34331/hello'



      And verify that the request was received and inspect the request to look at the headers if any were sent and the URL that was used for the request









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jun 22 at 13:06









      steve

      12.1k22047




      12.1k22047









      asked Jun 22 at 11:31









      user2352084

      82




      82




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          You can use netcat. Something like:



          nc -l 34331


          If you want to see the detail of a call, It'd be easier to use -v option of curl and call the real service.



          curl -v http://www.google.com > /dev/null
          * Connected to localhost (127.0.0.1) port 3128 (#0)
          > GET http://www.google.com/ HTTP/1.1
          > Host: www.google.com
          > User-Agent: curl/7.47.0
          > Accept: */*
          > Proxy-Connection: Keep-Alive
          >
          < HTTP/1.1 200 OK
          < Date: Fri, 22 Jun 2018 12:58:58 GMT
          < Expires: -1
          < Cache-Control: private, max-age=0
          < P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
          < Server: gws
          < X-XSS-Protection: 1; mode=block
          < X-Frame-Options: SAMEORIGIN
          < Set-Cookie: 1P_JAR=2018-06-22-12; expires=Sun, 22-Jul-2018 12:58:58 GMT; path=/; domain=.google.com
          < Set-Cookie: NID=132=cLF8pa3SHRsg32-ZGzN5aZ3ipLfAbxqfmUvJ2NTvkYg2eWN6XaOqSofMK7o902-C9hdxL_wUn6cJW2AkngcQXvNUKCCdNi7Z-eBTu0Yc8-iTFR90OeZDR44hxZK95_Ny; expires=Sat, 22-Dec-2018 12:58:58 GMT; path=/; domain=.google.com; HttpOnly
          < Accept-Ranges: none
          < Vary: Accept-Encoding
          < Transfer-Encoding: chunked
          < Content-Type: text/html; charset=ISO-8859-1
          < Connection: keep-alive
          < Proxy-Connection: keep-alive
          <
          { [2035 bytes data]
          100 11564 0 11564 0 0 69134 0 --:--:-- --:--:-- --:--:-- 68833
          * Connection #0 to host localhost left intact





          share|improve this answer






























            up vote
            0
            down vote













            If you have perl installed, a very simple http daemon can be written using HTTP::Daemon module (which you need to have in your perl libs):



            #!/usr/bin/perl
            use strict;
            use HTTP::Daemon;
            use HTTP::Response;
            use threads;

            my $httpd = HTTP::Daemon->new( LocalPort => 8081, Listen => 20, Reuse=>1) || die;
            print "httpd started...n";

            sub process_one_req

            my $con = shift;
            my $rq = $con->get_request;

            print "<< ".$rq->uri." : ".$rq->header('User-Agent')."n";

            my $rsp = HTTP::Response->new(200, 'OK' );
            $con->send_response($rsp);


            while (my $con = $httpd->accept)

            process_one_req $con;



            see also https://metacpan.org/pod/HTTP::Daemon






            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%2f451280%2fwhat-is-the-easiest-way-to-set-up-a-http-request-logger%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote



              accepted










              You can use netcat. Something like:



              nc -l 34331


              If you want to see the detail of a call, It'd be easier to use -v option of curl and call the real service.



              curl -v http://www.google.com > /dev/null
              * Connected to localhost (127.0.0.1) port 3128 (#0)
              > GET http://www.google.com/ HTTP/1.1
              > Host: www.google.com
              > User-Agent: curl/7.47.0
              > Accept: */*
              > Proxy-Connection: Keep-Alive
              >
              < HTTP/1.1 200 OK
              < Date: Fri, 22 Jun 2018 12:58:58 GMT
              < Expires: -1
              < Cache-Control: private, max-age=0
              < P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
              < Server: gws
              < X-XSS-Protection: 1; mode=block
              < X-Frame-Options: SAMEORIGIN
              < Set-Cookie: 1P_JAR=2018-06-22-12; expires=Sun, 22-Jul-2018 12:58:58 GMT; path=/; domain=.google.com
              < Set-Cookie: NID=132=cLF8pa3SHRsg32-ZGzN5aZ3ipLfAbxqfmUvJ2NTvkYg2eWN6XaOqSofMK7o902-C9hdxL_wUn6cJW2AkngcQXvNUKCCdNi7Z-eBTu0Yc8-iTFR90OeZDR44hxZK95_Ny; expires=Sat, 22-Dec-2018 12:58:58 GMT; path=/; domain=.google.com; HttpOnly
              < Accept-Ranges: none
              < Vary: Accept-Encoding
              < Transfer-Encoding: chunked
              < Content-Type: text/html; charset=ISO-8859-1
              < Connection: keep-alive
              < Proxy-Connection: keep-alive
              <
              { [2035 bytes data]
              100 11564 0 11564 0 0 69134 0 --:--:-- --:--:-- --:--:-- 68833
              * Connection #0 to host localhost left intact





              share|improve this answer



























                up vote
                2
                down vote



                accepted










                You can use netcat. Something like:



                nc -l 34331


                If you want to see the detail of a call, It'd be easier to use -v option of curl and call the real service.



                curl -v http://www.google.com > /dev/null
                * Connected to localhost (127.0.0.1) port 3128 (#0)
                > GET http://www.google.com/ HTTP/1.1
                > Host: www.google.com
                > User-Agent: curl/7.47.0
                > Accept: */*
                > Proxy-Connection: Keep-Alive
                >
                < HTTP/1.1 200 OK
                < Date: Fri, 22 Jun 2018 12:58:58 GMT
                < Expires: -1
                < Cache-Control: private, max-age=0
                < P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
                < Server: gws
                < X-XSS-Protection: 1; mode=block
                < X-Frame-Options: SAMEORIGIN
                < Set-Cookie: 1P_JAR=2018-06-22-12; expires=Sun, 22-Jul-2018 12:58:58 GMT; path=/; domain=.google.com
                < Set-Cookie: NID=132=cLF8pa3SHRsg32-ZGzN5aZ3ipLfAbxqfmUvJ2NTvkYg2eWN6XaOqSofMK7o902-C9hdxL_wUn6cJW2AkngcQXvNUKCCdNi7Z-eBTu0Yc8-iTFR90OeZDR44hxZK95_Ny; expires=Sat, 22-Dec-2018 12:58:58 GMT; path=/; domain=.google.com; HttpOnly
                < Accept-Ranges: none
                < Vary: Accept-Encoding
                < Transfer-Encoding: chunked
                < Content-Type: text/html; charset=ISO-8859-1
                < Connection: keep-alive
                < Proxy-Connection: keep-alive
                <
                { [2035 bytes data]
                100 11564 0 11564 0 0 69134 0 --:--:-- --:--:-- --:--:-- 68833
                * Connection #0 to host localhost left intact





                share|improve this answer

























                  up vote
                  2
                  down vote



                  accepted







                  up vote
                  2
                  down vote



                  accepted






                  You can use netcat. Something like:



                  nc -l 34331


                  If you want to see the detail of a call, It'd be easier to use -v option of curl and call the real service.



                  curl -v http://www.google.com > /dev/null
                  * Connected to localhost (127.0.0.1) port 3128 (#0)
                  > GET http://www.google.com/ HTTP/1.1
                  > Host: www.google.com
                  > User-Agent: curl/7.47.0
                  > Accept: */*
                  > Proxy-Connection: Keep-Alive
                  >
                  < HTTP/1.1 200 OK
                  < Date: Fri, 22 Jun 2018 12:58:58 GMT
                  < Expires: -1
                  < Cache-Control: private, max-age=0
                  < P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
                  < Server: gws
                  < X-XSS-Protection: 1; mode=block
                  < X-Frame-Options: SAMEORIGIN
                  < Set-Cookie: 1P_JAR=2018-06-22-12; expires=Sun, 22-Jul-2018 12:58:58 GMT; path=/; domain=.google.com
                  < Set-Cookie: NID=132=cLF8pa3SHRsg32-ZGzN5aZ3ipLfAbxqfmUvJ2NTvkYg2eWN6XaOqSofMK7o902-C9hdxL_wUn6cJW2AkngcQXvNUKCCdNi7Z-eBTu0Yc8-iTFR90OeZDR44hxZK95_Ny; expires=Sat, 22-Dec-2018 12:58:58 GMT; path=/; domain=.google.com; HttpOnly
                  < Accept-Ranges: none
                  < Vary: Accept-Encoding
                  < Transfer-Encoding: chunked
                  < Content-Type: text/html; charset=ISO-8859-1
                  < Connection: keep-alive
                  < Proxy-Connection: keep-alive
                  <
                  { [2035 bytes data]
                  100 11564 0 11564 0 0 69134 0 --:--:-- --:--:-- --:--:-- 68833
                  * Connection #0 to host localhost left intact





                  share|improve this answer















                  You can use netcat. Something like:



                  nc -l 34331


                  If you want to see the detail of a call, It'd be easier to use -v option of curl and call the real service.



                  curl -v http://www.google.com > /dev/null
                  * Connected to localhost (127.0.0.1) port 3128 (#0)
                  > GET http://www.google.com/ HTTP/1.1
                  > Host: www.google.com
                  > User-Agent: curl/7.47.0
                  > Accept: */*
                  > Proxy-Connection: Keep-Alive
                  >
                  < HTTP/1.1 200 OK
                  < Date: Fri, 22 Jun 2018 12:58:58 GMT
                  < Expires: -1
                  < Cache-Control: private, max-age=0
                  < P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
                  < Server: gws
                  < X-XSS-Protection: 1; mode=block
                  < X-Frame-Options: SAMEORIGIN
                  < Set-Cookie: 1P_JAR=2018-06-22-12; expires=Sun, 22-Jul-2018 12:58:58 GMT; path=/; domain=.google.com
                  < Set-Cookie: NID=132=cLF8pa3SHRsg32-ZGzN5aZ3ipLfAbxqfmUvJ2NTvkYg2eWN6XaOqSofMK7o902-C9hdxL_wUn6cJW2AkngcQXvNUKCCdNi7Z-eBTu0Yc8-iTFR90OeZDR44hxZK95_Ny; expires=Sat, 22-Dec-2018 12:58:58 GMT; path=/; domain=.google.com; HttpOnly
                  < Accept-Ranges: none
                  < Vary: Accept-Encoding
                  < Transfer-Encoding: chunked
                  < Content-Type: text/html; charset=ISO-8859-1
                  < Connection: keep-alive
                  < Proxy-Connection: keep-alive
                  <
                  { [2035 bytes data]
                  100 11564 0 11564 0 0 69134 0 --:--:-- --:--:-- --:--:-- 68833
                  * Connection #0 to host localhost left intact






                  share|improve this answer















                  share|improve this answer



                  share|improve this answer








                  edited Jun 22 at 13:13


























                  answered Jun 22 at 13:05









                  andcoz

                  11.5k32938




                  11.5k32938






















                      up vote
                      0
                      down vote













                      If you have perl installed, a very simple http daemon can be written using HTTP::Daemon module (which you need to have in your perl libs):



                      #!/usr/bin/perl
                      use strict;
                      use HTTP::Daemon;
                      use HTTP::Response;
                      use threads;

                      my $httpd = HTTP::Daemon->new( LocalPort => 8081, Listen => 20, Reuse=>1) || die;
                      print "httpd started...n";

                      sub process_one_req

                      my $con = shift;
                      my $rq = $con->get_request;

                      print "<< ".$rq->uri." : ".$rq->header('User-Agent')."n";

                      my $rsp = HTTP::Response->new(200, 'OK' );
                      $con->send_response($rsp);


                      while (my $con = $httpd->accept)

                      process_one_req $con;



                      see also https://metacpan.org/pod/HTTP::Daemon






                      share|improve this answer

























                        up vote
                        0
                        down vote













                        If you have perl installed, a very simple http daemon can be written using HTTP::Daemon module (which you need to have in your perl libs):



                        #!/usr/bin/perl
                        use strict;
                        use HTTP::Daemon;
                        use HTTP::Response;
                        use threads;

                        my $httpd = HTTP::Daemon->new( LocalPort => 8081, Listen => 20, Reuse=>1) || die;
                        print "httpd started...n";

                        sub process_one_req

                        my $con = shift;
                        my $rq = $con->get_request;

                        print "<< ".$rq->uri." : ".$rq->header('User-Agent')."n";

                        my $rsp = HTTP::Response->new(200, 'OK' );
                        $con->send_response($rsp);


                        while (my $con = $httpd->accept)

                        process_one_req $con;



                        see also https://metacpan.org/pod/HTTP::Daemon






                        share|improve this answer























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          If you have perl installed, a very simple http daemon can be written using HTTP::Daemon module (which you need to have in your perl libs):



                          #!/usr/bin/perl
                          use strict;
                          use HTTP::Daemon;
                          use HTTP::Response;
                          use threads;

                          my $httpd = HTTP::Daemon->new( LocalPort => 8081, Listen => 20, Reuse=>1) || die;
                          print "httpd started...n";

                          sub process_one_req

                          my $con = shift;
                          my $rq = $con->get_request;

                          print "<< ".$rq->uri." : ".$rq->header('User-Agent')."n";

                          my $rsp = HTTP::Response->new(200, 'OK' );
                          $con->send_response($rsp);


                          while (my $con = $httpd->accept)

                          process_one_req $con;



                          see also https://metacpan.org/pod/HTTP::Daemon






                          share|improve this answer













                          If you have perl installed, a very simple http daemon can be written using HTTP::Daemon module (which you need to have in your perl libs):



                          #!/usr/bin/perl
                          use strict;
                          use HTTP::Daemon;
                          use HTTP::Response;
                          use threads;

                          my $httpd = HTTP::Daemon->new( LocalPort => 8081, Listen => 20, Reuse=>1) || die;
                          print "httpd started...n";

                          sub process_one_req

                          my $con = shift;
                          my $rq = $con->get_request;

                          print "<< ".$rq->uri." : ".$rq->header('User-Agent')."n";

                          my $rsp = HTTP::Response->new(200, 'OK' );
                          $con->send_response($rsp);


                          while (my $con = $httpd->accept)

                          process_one_req $con;



                          see also https://metacpan.org/pod/HTTP::Daemon







                          share|improve this answer













                          share|improve this answer



                          share|improve this answer











                          answered Jun 22 at 13:09









                          tonioc

                          1,10457




                          1,10457






















                               

                              draft saved


                              draft discarded


























                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451280%2fwhat-is-the-easiest-way-to-set-up-a-http-request-logger%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Popular posts from this blog

                              Peggy Mitchell

                              Palaiologos

                              The Forum (Inglewood, California)