Skip to content

Instantly share code, notes, and snippets.

@ericksond
Created September 14, 2016 17:58
Show Gist options
  • Save ericksond/c591064b684d50f8a08dfbd933e316ec to your computer and use it in GitHub Desktop.
Save ericksond/c591064b684d50f8a08dfbd933e316ec to your computer and use it in GitHub Desktop.
HTTP POST Request Dump to HTTP/1.x Wire
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
dump, err := httputil.DumpRequest(r, true)
if err != nil {
fmt.Println(err)
http.Error(w, fmt.Sprint(err), http.StatusInternalServerError)
return
}
fmt.Println(string(dump))
// fmt.Fprintf(w, "%q", dump)
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment