Created
January 21, 2016 17:24
-
-
Save jordanorelli/5c0680e37e96dfc4391b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
"flag" | |
"fmt" | |
"net/http" | |
"net/http/httputil" | |
"os" | |
"time" | |
) | |
var options struct { | |
port int | |
hostname string | |
} | |
func timeout(w http.ResponseWriter, r *http.Request) { | |
dump, err := httputil.DumpRequest(r, true) | |
if err == nil { | |
os.Stdout.Write(dump) | |
} | |
time.Sleep(time.Hour) | |
} | |
func main() { | |
flag.Parse() | |
addr := fmt.Sprintf("%s:%d", options.hostname, options.port) | |
fmt.Printf("listening on %s\n", addr) | |
http.HandleFunc("/", timeout) | |
err := http.ListenAndServe(addr, nil) | |
if err != nil { | |
fmt.Println("error: %v", err) | |
} | |
} | |
func init() { | |
flag.IntVar(&options.port, "port", 9001, "incoming http port") | |
flag.StringVar(&options.hostname, "host", "0.0.0.0", "incoming hostname") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
timeout server. all requests sent to this server will time out. used for testing clients.