forked from quic-go/quic-go
Merge pull request #1348 from lucas-clemente/httpguts
use H2 helper functions from httpguts repository
This commit is contained in:
@@ -8,9 +8,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"golang.org/x/net/http/httpguts"
|
||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
"golang.org/x/net/http2/hpack"
|
"golang.org/x/net/http2/hpack"
|
||||||
"golang.org/x/net/lex/httplex"
|
|
||||||
|
|
||||||
quic "github.com/lucas-clemente/quic-go"
|
quic "github.com/lucas-clemente/quic-go"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
@@ -65,7 +65,7 @@ func (w *requestWriter) encodeHeaders(req *http.Request, addGzipHeader bool, tra
|
|||||||
if host == "" {
|
if host == "" {
|
||||||
host = req.URL.Host
|
host = req.URL.Host
|
||||||
}
|
}
|
||||||
host, err := httplex.PunycodeHostPort(host)
|
host, err := httpguts.PunycodeHostPort(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -89,11 +89,11 @@ func (w *requestWriter) encodeHeaders(req *http.Request, addGzipHeader bool, tra
|
|||||||
// potentially pollute our hpack state. (We want to be able to
|
// potentially pollute our hpack state. (We want to be able to
|
||||||
// continue to reuse the hpack encoder for future requests)
|
// continue to reuse the hpack encoder for future requests)
|
||||||
for k, vv := range req.Header {
|
for k, vv := range req.Header {
|
||||||
if !httplex.ValidHeaderFieldName(k) {
|
if !httpguts.ValidHeaderFieldName(k) {
|
||||||
return nil, fmt.Errorf("invalid HTTP header name %q", k)
|
return nil, fmt.Errorf("invalid HTTP header name %q", k)
|
||||||
}
|
}
|
||||||
for _, v := range vv {
|
for _, v := range vv {
|
||||||
if !httplex.ValidHeaderFieldValue(v) {
|
if !httpguts.ValidHeaderFieldValue(v) {
|
||||||
return nil, fmt.Errorf("invalid HTTP header value %q for header %q", v, k)
|
return nil, fmt.Errorf("invalid HTTP header value %q for header %q", v, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
quic "github.com/lucas-clemente/quic-go"
|
quic "github.com/lucas-clemente/quic-go"
|
||||||
|
|
||||||
"golang.org/x/net/lex/httplex"
|
"golang.org/x/net/http/httpguts"
|
||||||
)
|
)
|
||||||
|
|
||||||
type roundTripCloser interface {
|
type roundTripCloser interface {
|
||||||
@@ -80,11 +80,11 @@ func (r *RoundTripper) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.
|
|||||||
|
|
||||||
if req.URL.Scheme == "https" {
|
if req.URL.Scheme == "https" {
|
||||||
for k, vv := range req.Header {
|
for k, vv := range req.Header {
|
||||||
if !httplex.ValidHeaderFieldName(k) {
|
if !httpguts.ValidHeaderFieldName(k) {
|
||||||
return nil, fmt.Errorf("quic: invalid http header field name %q", k)
|
return nil, fmt.Errorf("quic: invalid http header field name %q", k)
|
||||||
}
|
}
|
||||||
for _, v := range vv {
|
for _, v := range vv {
|
||||||
if !httplex.ValidHeaderFieldValue(v) {
|
if !httpguts.ValidHeaderFieldValue(v) {
|
||||||
return nil, fmt.Errorf("quic: invalid http header field value %q for key %v", v, k)
|
return nil, fmt.Errorf("quic: invalid http header field value %q for key %v", v, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,5 +175,5 @@ func validMethod(method string) bool {
|
|||||||
|
|
||||||
// copied from net/http/http.go
|
// copied from net/http/http.go
|
||||||
func isNotToken(r rune) bool {
|
func isNotToken(r rune) bool {
|
||||||
return !httplex.IsTokenRune(r)
|
return !httpguts.IsTokenRune(r)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user