54 lines
1023 B
Go
54 lines
1023 B
Go
package main
|
|
|
|
import (
|
|
// "fmt"
|
|
"log"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func dumpClient(r *http.Request) {
|
|
// Basic request information
|
|
log.Println("Method:", r.Method)
|
|
log.Println("URL:", r.URL)
|
|
log.Println("Protocol:", r.Proto)
|
|
log.Println("Host:", r.Host)
|
|
log.Println("Remote Address:", r.RemoteAddr)
|
|
|
|
// Headers
|
|
log.Println("Headers:")
|
|
for name, values := range r.Header {
|
|
for _, value := range values {
|
|
log.Println(name, value)
|
|
}
|
|
}
|
|
|
|
// Query parameters
|
|
log.Println("Query Parameters:")
|
|
for param, values := range r.URL.Query() {
|
|
for _, value := range values {
|
|
log.Println(param, value)
|
|
}
|
|
}
|
|
|
|
// User-Agent
|
|
log.Println("User-Agent:", r.UserAgent())
|
|
|
|
// Content Length
|
|
log.Println("Content Length:", r.ContentLength)
|
|
|
|
// Cookies
|
|
log.Println("Cookies:")
|
|
for _, cookie := range r.Cookies() {
|
|
log.Println(cookie.Name, cookie.Value)
|
|
}
|
|
|
|
// Request Body (if applicable)
|
|
if r.Body != nil {
|
|
body, err := ioutil.ReadAll(r.Body)
|
|
if err == nil {
|
|
log.Println("Body:", string(body))
|
|
}
|
|
}
|
|
}
|