Created
February 20, 2017 14:40
-
-
Save kjmkznr/28484df7106cc433a78343b183db21ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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