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 |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 // of the server's certificate followed by the CA's certificate. | 1077 // of the server's certificate followed by the CA's certificate. |
1078 // | 1078 // |
1079 // If srv.Addr is blank, ":https" is used. | 1079 // If srv.Addr is blank, ":https" is used. |
1080 func (s *Server) ListenAndServeTLS(certFile, keyFile string) error { | 1080 func (s *Server) ListenAndServeTLS(certFile, keyFile string) error { |
1081 addr := s.Addr | 1081 addr := s.Addr |
1082 if addr == "" { | 1082 if addr == "" { |
1083 addr = ":https" | 1083 addr = ":https" |
1084 } | 1084 } |
1085 config := &tls.Config{ | 1085 config := &tls.Config{ |
1086 Rand: rand.Reader, | 1086 Rand: rand.Reader, |
1087 » » NextProtos: []string{"http/1.1"}, | 1087 » » NextProtos: {"http/1.1"}, |
1088 } | 1088 } |
1089 | 1089 |
1090 var err error | 1090 var err error |
1091 config.Certificates = make([]tls.Certificate, 1) | 1091 config.Certificates = make([]tls.Certificate, 1) |
1092 config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile) | 1092 config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile) |
1093 if err != nil { | 1093 if err != nil { |
1094 return err | 1094 return err |
1095 } | 1095 } |
1096 | 1096 |
1097 conn, err := net.Listen("tcp", addr) | 1097 conn, err := net.Listen("tcp", addr) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 func (tw *timeoutWriter) WriteHeader(code int) { | 1181 func (tw *timeoutWriter) WriteHeader(code int) { |
1182 tw.mu.Lock() | 1182 tw.mu.Lock() |
1183 if tw.timedOut || tw.wroteHeader { | 1183 if tw.timedOut || tw.wroteHeader { |
1184 tw.mu.Unlock() | 1184 tw.mu.Unlock() |
1185 return | 1185 return |
1186 } | 1186 } |
1187 tw.wroteHeader = true | 1187 tw.wroteHeader = true |
1188 tw.mu.Unlock() | 1188 tw.mu.Unlock() |
1189 tw.w.WriteHeader(code) | 1189 tw.w.WriteHeader(code) |
1190 } | 1190 } |
OLD | NEW |