Skip to content

Commit

Permalink
Set Content-Length
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarham committed May 31, 2012
1 parent 570a7a0 commit 4beb081
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func indexHandler(w http.ResponseWriter, req *http.Request) {
Counter: fmt.Sprint(counter), Counter: fmt.Sprint(counter),
Host: req.Host, Host: req.Host,
} }
w.Header().Set("Cache-Control", "no-cache")
index.Execute(w, params) index.Execute(w, params)
} }


Expand All @@ -98,13 +99,16 @@ func apiHandler(w http.ResponseWriter, req *http.Request) {
} }
w.Header().Set("Content-Type", "text/plain") w.Header().Set("Content-Type", "text/plain")
w.Header().Set("Cache-Control", "no-cache") w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("Content-Length", strconv.Itoa(n))
fmt.Fprint(w, getPassword()[:n]) fmt.Fprint(w, getPassword()[:n])
} }


func counterHandler(w http.ResponseWriter, req *http.Request) { func counterHandler(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/plain") w.Header().Set("Content-Type", "text/plain")
w.Header().Set("Cache-Control", "no-cache") w.Header().Set("Cache-Control", "no-cache")
fmt.Fprint(w, counter) s := strconv.FormatUint(counter, 10)
w.Header().Set("Content-Length", strconv.Itoa(len(s)))
fmt.Fprint(w, s)
} }


func generatePasswords() { func generatePasswords() {
Expand Down

0 comments on commit 4beb081

Please sign in to comment.