Skip to content

Instantly share code, notes, and snippets.

@kjmkznr
Created February 20, 2017 14:40
Show Gist options
  • Save kjmkznr/28484df7106cc433a78343b183db21ea to your computer and use it in GitHub Desktop.
Save kjmkznr/28484df7106cc433a78343b183db21ea to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"flag"
"fmt"
"io"
"log"
"net/http"
"strconv"
)
func handler(w http.ResponseWriter, r *http.Request) {
var buf bytes.Buffer
mw := io.MultiWriter(w, &buf)
r.Write(mw)
log.Print(buf.String())
}
func xsshandler(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
fmt.Fprintf(w, "<html><body>%s</body></html>", r.Form.Get("foo"))
}
func main() {
port := flag.Int("port", 8080, "Listen on port")
flag.Parse()
http.HandleFunc("/", handler)
http.HandleFunc("/xss", xsshandler)
log.Println("Starting http server on port:", *port)
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment