2

I have a simple rails app and it is sending http requests to a server which then displays the results in UI.

I just want to count the number of requests that I send and the request and response for each http request.

Is there any gem or utility to automatically collect tear requests or do I need to write custom code for that?

EDIT

I need to get the number of requests in my rails app so that future requests will be sent based on the count provided by the tools. So either the tool has to be integrated with my rails app or it needs to provide API access to get the count.

  • 1
    Please see also this similar question which has a number of recommendations. – Misha Brukman Dec 24 '15 at 5:25
  • 1
    Please clarify whether you are aiming to log everything (i.e., the full content of the response, which is the entire HTML page, or JS, or binary data for images) or you are just looking to get a count of hits for different URLs with HTTP status codes, which is what is typically done by web server stats analysis software. – Misha Brukman Dec 24 '15 at 16:06
  • @MishaBrukman For now, just the count is enough – Samuel Alexander Dec 28 '15 at 5:03
  • How'd it go? Get what you need? – voices Dec 30 '15 at 7:13
  • 1
    I don't have much experience with ruby, but I would have thought that anything capable of .pcap output, ought to be suitable.. – voices Dec 30 '15 at 12:36
2
+50

Maybe something like httpry will be better suited to your purpose.
More info can be found at: http://dumpsterventures.com/jason/httpry.
The code is hosted by GitHub: https://github.com/jbittel/httpry.

httpry version 0.1.8 -- HTTP logging and information retrieval tool
Copyright (c) 2005-2014 Jason Bittel 
Usage: httpry [ -dFhpqs ] [-b file ] [ -f format ] [ -i device ] [ -l threshold ]
              [ -m methods ] [ -n count ] [ -o file ] [ -P file ] [ -r file ]
              [ -t seconds] [ -u user ] [ 'expression' ]

   -b file      write HTTP packets to a binary dump file
   -d           run as daemon
   -f format    specify output format string
   -F           force output flush
   -h           print this help information
   -i device    listen on this interface
   -l threshold specify a rps threshold for rate statistics
   -m methods   specify request methods to parse
   -n count     set number of HTTP packets to parse
   -o file      write output to a file
   -p           disable promiscuous mode
   -P file      use custom PID filename when running in daemon mode 
   -q           suppress non-critical output
   -r file      read packets from input file
   -s           run in HTTP requests per second mode
   -t seconds   specify the display interval for rate statistics
   -u user      set process owner
   expression   specify a bpf-style capture filter

This is the output when I refresh this page:

httpry


If you want to pipe the output into other programs, (like grep for instance) use -F.

-F Disable all output buffering. 
   This may be helpful when piping httpry output into another program.
|improve this answer|||||
  • If you like this idea; it might also be worth your while to check out tcpdump, tshark, winpcap, etc. – voices Dec 30 '15 at 12:29
2

Try Portswigger's Burp Suite.
https://portswigger.net/burp/download.html

Burp

|improve this answer|||||
  • Just an info that might help keep you out of trouble: downloading the burp suite at the company I am employed rings every available alarm bell ... Because some anti malware tools consider the burp suite a "hacker tool" both the proxy and the client side antivirus yell like hell. – Marged Dec 26 '15 at 21:48
  • Does Burp provide API to get the count of http request for a site? – Samuel Alexander Dec 28 '15 at 5:16
  • @SamuelAlexander It allows you to set the target scope and filter for whatever domain or address you like and creates a numbered list, like in the image. Does that help? – voices Dec 28 '15 at 6:26
  • @tjt263 Apart from Burp UI(shown in image), is there any other way to get that count? Something like getting the count by executing a http call or ruby code against Burp. – Samuel Alexander Dec 28 '15 at 13:34
2

I am using fiddler to achieve that for my work.

  • Fiddler can capture the requests from the entire PC or any specific process or any specific application by dragging icon to the window
  • You can see the request and responses from the side tab for each request.
  • You can resend the requests if you want through it's neat UI.
  • You can log the requests for a specific web browser or a particular user-agent.
  • Option to export and import the sessions
  • Option to create custom rules
  • Option to minimize to tray and runs in background.
  • Option to hide Image requests.

There are also a lot of interesting Addons available for this like you can flip the images that are coming in response, traffic differ, privacy scanner requests that set cookies. Debug traffic from any location in the world. Supports all platforms.

enter image description here

|improve this answer|||||
  • Does Fiddler provide API to get the count of http request for a site? – Samuel Alexander Dec 28 '15 at 5:16
2

If don't need as many functions that burp and fiddler offer you can go for Membrane Soap Monitor. Because it is a Java based application it runs on Linux, Mac OS and Windows.

Just download and unzip, the provided .exe will automatically find your Java Runtime. Then create a simple proxy and leave all values unchanged except those where you have to give the name of your targetted server:

enter image description here

After that simply have your software address the proxy as if it were a normal http endpoint (I am using curl in my example):

curl http://localhost:2000/foo

Membrane will then show you the exchange with details (incoming and outgoing headers too) and count the number of exchanges:

enter image description here

I have worked with both Fiddler and the Burp Proxy which both are great tools and offer functionality that goes way beyond what Membrane is able to do. But if you need a simple to set up proxy I suggest using Membrane.

|improve this answer|||||
  • Does Fiddler or Burp provide API to get the count of http request for a site? See my edited question – Samuel Alexander Dec 28 '15 at 5:16
  • @SamuelAlexander In Fiddler you can set a filter for a process (for example include only your rails app) but I do not know a way to restrict to a specific site (but you could exclude a certain URL). Membrane makes this much more easier: define a proxy exclusively for your app and then you can see the n of n Exchanges (see my screenshot) – Marged Dec 28 '15 at 6:49
  • So limiting the http call will be taken care by Fiddler. We don't need to limit the calls in our rails app. Is that what you mean? If that is the case it will be useful, but still getting the count by executing a curl command or via ruby|rails code against Fiddler will be great. Is that available in Fiddler? – Samuel Alexander Dec 28 '15 at 13:37
  • 1
    After you edited your question: I don't think it makes sense to count the number of calls using a proxy if you need to have the count inside your application. In Java I would write a ServletFilter or Interceptor for that, you should see if this is available in rails. – Marged Dec 28 '15 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.