OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // HTTP server. See RFC 2616. | 5 // HTTP server. See RFC 2616. |
6 | 6 |
7 // TODO(rsc): | 7 // TODO(rsc): |
8 // logging | 8 // logging |
9 | 9 |
10 package http | 10 package http |
11 | 11 |
12 import ( | 12 import ( |
13 "bufio" | 13 "bufio" |
14 "bytes" | 14 "bytes" |
15 "crypto/rand" | 15 "crypto/rand" |
16 "crypto/tls" | 16 "crypto/tls" |
17 "errors" | 17 "errors" |
18 "fmt" | 18 "fmt" |
19 "io" | 19 "io" |
20 "io/ioutil" | 20 "io/ioutil" |
21 "log" | 21 "log" |
22 "net" | 22 "net" |
| 23 "net/url" |
23 "path" | 24 "path" |
24 "runtime/debug" | 25 "runtime/debug" |
25 "strconv" | 26 "strconv" |
26 "strings" | 27 "strings" |
27 "sync" | 28 "sync" |
28 "time" | 29 "time" |
29 "url" | |
30 ) | 30 ) |
31 | 31 |
32 // Errors introduced by the HTTP server. | 32 // Errors introduced by the HTTP server. |
33 var ( | 33 var ( |
34 ErrWriteAfterFlush = errors.New("Conn.Write called after Flush") | 34 ErrWriteAfterFlush = errors.New("Conn.Write called after Flush") |
35 ErrBodyNotAllowed = errors.New("http: response status code does not all
ow body") | 35 ErrBodyNotAllowed = errors.New("http: response status code does not all
ow body") |
36 ErrHijacked = errors.New("Conn has been hijacked") | 36 ErrHijacked = errors.New("Conn has been hijacked") |
37 ErrContentLength = errors.New("Conn.Write wrote more than the declared
Content-Length") | 37 ErrContentLength = errors.New("Conn.Write wrote more than the declared
Content-Length") |
38 ) | 38 ) |
39 | 39 |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 func (tw *timeoutWriter) WriteHeader(code int) { | 1180 func (tw *timeoutWriter) WriteHeader(code int) { |
1181 tw.mu.Lock() | 1181 tw.mu.Lock() |
1182 if tw.timedOut || tw.wroteHeader { | 1182 if tw.timedOut || tw.wroteHeader { |
1183 tw.mu.Unlock() | 1183 tw.mu.Unlock() |
1184 return | 1184 return |
1185 } | 1185 } |
1186 tw.wroteHeader = true | 1186 tw.wroteHeader = true |
1187 tw.mu.Unlock() | 1187 tw.mu.Unlock() |
1188 tw.w.WriteHeader(code) | 1188 tw.w.WriteHeader(code) |
1189 } | 1189 } |
OLD | NEW |