File: format-string

package info (click to toggle)
httpry 0.1.8-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 436 kB
  • sloc: ansic: 1,358; perl: 1,336; sh: 155; makefile: 62
file content (66 lines) | stat: -rw-r--r-- 2,692 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
The -f switch allows the user to provide a format string that tells httpry
which fields to print from each HTTP packet. The string is a comma-
delimited list of elements, examples of which are provided below. The format
strings can have spaces between elements and are _not_ case sensitive.
Duplicate field names are ignored.

An example, you say? The default format string looks like this:

   timestamp,source-ip,dest-ip,direction,method,host,request-uri,
      http-version,status-code,reason-phrase

The output will look something like this for a request and a response (a '-'
character indicates no data for that field):

   06/05/2006 15:32:31 192.168.0.15 66.102.7.104 > GET www.google.com /
      HTTP/1.1 - -
   06/05/2006 15:32:31 66.102.7.104 192.168.0.15 < - - - HTTP/1.1 200 OK

In these two example lines the fields are space delimited for readability,
but the standard output from httpry is tab delimited. There are eleven special
(i.e. outside the body of the HTTP request) fields that can be specified in
the format string:

   Timestamp        Request-URI
   Source-IP        Method
   Source-Port      HTTP-Version
   Dest-IP          Status-Code
   Dest-Port        Reason-Phrase
   Direction

Most of these are fields from the header line of each request or response.
The direction field will print a chevron with '>' indicating a client request
and '<' indicating a server response.

The program can parse any header field found in the packet, even custom
headers not included in the HTTP standard. For reference, here is a list of
the standard RFC2616 headers:

   Accept                  If-None-Match
   Accept-Charset          If-Range
   Accept-Encoding         If-Unmodified-Since
   Accept-Language         Max-Forwards
   Authorization           Proxy-Authorization
   Expect                  Range
   From                    Referer
   Host                    TE
   If-Match                User-Agent
   If-Modified-Since

Of course there are other request header fields, but this provides a starting
point. Here are some example format strings:

   host,user-agent
   referer,request-uri,http-version
   source-ip,x-forwarded-for,user-agent
   timestamp,source-ip,dest-ip,direction,host,request-uri
   status-code,reason-phrase,my-custom-header-field

There is no limit on the length of the format string. This provides a
reasonably flexible method for specifying the output string, while still
supporting custom fields. Input order is maintained so you can position the
fields in the output string.

If you consistently use a custom format string and don't want to specify it
every run, just modify the default format string in config.h and recompile
httpry.