Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created January 21, 2016 17:24
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")
}
@jordanorelli
Copy link
Author

timeout server. all requests sent to this server will time out. used for testing clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment