Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1009)

Unified Diff: src/pkg/http/fs.go

Issue 4239076: code review 4239076: http: change ResponseWriter.SetHeader(k,v) to Header() ... (Closed)
Patch Set: diff -r a5f4ae5ff5fa https://go.googlecode.com/hg/ Created 13 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/http/cgi/matryoshka_test.go ('k') | src/pkg/http/httptest/recorder.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/http/fs.go
===================================================================
--- a/src/pkg/http/fs.go
+++ b/src/pkg/http/fs.go
@@ -108,7 +108,7 @@
w.WriteHeader(StatusNotModified)
return
}
- w.SetHeader("Last-Modified", time.SecondsToUTC(d.Mtime_ns/1e9).Format(TimeFormat))
+ w.Header().Set("Last-Modified", time.SecondsToUTC(d.Mtime_ns/1e9).Format(TimeFormat))
// use contents of index.html for directory, if present
if d.IsDirectory() {
@@ -137,16 +137,16 @@
// use extension to find content type.
ext := filepath.Ext(name)
if ctype := mime.TypeByExtension(ext); ctype != "" {
- w.SetHeader("Content-Type", ctype)
+ w.Header().Set("Content-Type", ctype)
} else {
// read first chunk to decide between utf-8 text and binary
var buf [1024]byte
n, _ := io.ReadFull(f, buf[:])
b := buf[:n]
if isText(b) {
- w.SetHeader("Content-Type", "text-plain; charset=utf-8")
+ w.Header().Set("Content-Type", "text-plain; charset=utf-8")
} else {
- w.SetHeader("Content-Type", "application/octet-stream") // generic binary
+ w.Header().Set("Content-Type", "application/octet-stream") // generic binary
}
f.Seek(0, 0) // rewind to output whole file
}
@@ -166,11 +166,11 @@
}
size = ra.length
code = StatusPartialContent
- w.SetHeader("Content-Range", fmt.Sprintf("bytes %d-%d/%d", ra.start, ra.start+ra.length-1, d.Size))
+ w.Header().Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", ra.start, ra.start+ra.length-1, d.Size))
}
- w.SetHeader("Accept-Ranges", "bytes")
- w.SetHeader("Content-Length", strconv.Itoa64(size))
+ w.Header().Set("Accept-Ranges", "bytes")
+ w.Header().Set("Content-Length", strconv.Itoa64(size))
w.WriteHeader(code)
« no previous file with comments | « src/pkg/http/cgi/matryoshka_test.go ('k') | src/pkg/http/httptest/recorder.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b