Commit dc19b94b authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: add optional Server.TLSConfig field

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5688047
parent dff5535a
...@@ -12,7 +12,6 @@ package http ...@@ -12,7 +12,6 @@ package http
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"crypto/rand"
"crypto/tls" "crypto/tls"
"errors" "errors"
"fmt" "fmt"
...@@ -985,6 +984,7 @@ type Server struct { ...@@ -985,6 +984,7 @@ type Server struct {
ReadTimeout time.Duration // maximum duration before timing out read of the request ReadTimeout time.Duration // maximum duration before timing out read of the request
WriteTimeout time.Duration // maximum duration before timing out write of the response WriteTimeout time.Duration // maximum duration before timing out write of the response
MaxHeaderBytes int // maximum size of request headers, DefaultMaxHeaderBytes if 0 MaxHeaderBytes int // maximum size of request headers, DefaultMaxHeaderBytes if 0
TLSConfig *tls.Config // optional TLS config, used by ListenAndServeTLS
} }
// ListenAndServe listens on the TCP network address srv.Addr and then // ListenAndServe listens on the TCP network address srv.Addr and then
...@@ -1121,9 +1121,12 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error { ...@@ -1121,9 +1121,12 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error {
if addr == "" { if addr == "" {
addr = ":https" addr = ":https"
} }
config := &tls.Config{ config := &tls.Config{}
Rand: rand.Reader, if srv.TLSConfig != nil {
NextProtos: []string{"http/1.1"}, *config = *srv.TLSConfig
}
if config.NextProtos == nil {
config.NextProtos = []string{"http/1.1"}
} }
var err error var err error
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment