Skip to content

Instantly share code, notes, and snippets.

@yomusu
Created October 24, 2014 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yomusu/d9df778e67502677747f to your computer and use it in GitHub Desktop.
Save yomusu/d9df778e67502677747f to your computer and use it in GitHub Desktop.
go : Chunked Transfer HTTP Server
package main
import (
"fmt"
"net/http"
"time"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.(http.Flusher).Flush()
time.Sleep(2000 * time.Millisecond)
fmt.Fprintln(w, "one")
w.(http.Flusher).Flush()
time.Sleep(2000 * time.Millisecond)
fmt.Fprintln(w, "two")
w.(http.Flusher).Flush()
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8085", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment