asciimoo / wuzz

Interactive cli tool for HTTP inspection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Trailers

andradei opened this issue · comments

When the Transfer-Encoding: chunked header is used, wuzz could show the Trailer header and the Trailer data. Just like curl.

For example:

The http.ResponseWriter Trailer example sets Trailer headers, then sends the body, then sends the actual Trailer headers. The actual example is pasted below for convenience:

mux := http.NewServeMux()
mux.HandleFunc("/sendstrailers", func(w http.ResponseWriter, req *http.Request) {
    // Before any call to WriteHeader or Write, declare
    // the trailers you will set during the HTTP
    // response. These three headers are actually sent in
    // the trailer.
    w.Header().Set("Trailer", "AtEnd1, AtEnd2")
    w.Header().Add("Trailer", "AtEnd3")

    w.Header().Set("Content-Type", "text/plain; charset=utf-8") // normal header
    w.WriteHeader(http.StatusOK)

    w.Header().Set("AtEnd1", "value 1")
    io.WriteString(w, "This HTTP response has both headers before this text and trailers at the end.\n")
    w.Header().Set("AtEnd2", "value 2")
    w.Header().Set("AtEnd3", "value 3") // These will appear as trailers.
})

curl --raw -v localhost:8000/ shows:

*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8000 (#0)
> GET / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.51.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
< Trailer: AtEnd1, AtEnd2
< Trailer: AtEnd3
< Date: Thu, 20 Apr 2017 03:38:33 GMT
< Transfer-Encoding: chunked
<
4e
This HTTP response has both headers before this text and trailers at the end.

0
Atend1: value 1
Atend2: value 2
Atend3: value 3

* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact

wuzz Just shows:

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Thu, 20 Apr 2017 03:31:13 GMT

@andradei Would you mind checking if #114 fixed this issue and closing this issue if everything is OK?

Looks good. Thank you.