Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created January 21, 2016 17:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jordanorelli/5c0680e37e96dfc4391b to your computer and use it in GitHub Desktop.
Save jordanorelli/5c0680e37e96dfc4391b to your computer and use it in GitHub Desktop.
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