add vendor

This commit is contained in:
deepzz0
2017-02-18 15:23:57 +08:00
parent 4ebbc38cc0
commit 562f4d86c6
1371 changed files with 369552 additions and 2 deletions
+66
View File
@@ -0,0 +1,66 @@
package rpc
import (
"fmt"
"net/http"
"testing"
)
// --------------------------------------------------------------------
func TestNewRequest(t *testing.T) {
req, err := http.NewRequest("GET", "-H\t abc.com \thttp://127.0.0.1/foo/bar", nil)
if err != nil {
t.Fatal("http.NewRequest failed")
}
if req.Host != "" {
t.Fatal(`http.NewRequest: req.Host != ""`)
}
req, err = newRequest("GET", "-H\t abc.com \thttp://127.0.0.1/foo/bar", nil)
if err != nil {
t.Fatal("newRequest failed:", err)
}
fmt.Println("Host:", req.Host, "path:", req.URL.Path, "url.host:", req.URL.Host)
if req.Host != "abc.com" || req.URL.Path != "/foo/bar" || req.URL.Host != "127.0.0.1" {
t.Fatal(`req.Host != "abc.com" || req.URL.Path != "/foo/bar" || req.URL.Host != "127.0.0.1"`)
}
}
// --------------------------------------------------------------------
type transport struct {
a http.RoundTripper
}
func (p *transport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
return p.a.RoundTrip(req)
}
func (p *transport) NestedObject() interface{} {
return p.a
}
func Test_getRequestCanceler(t *testing.T) {
p := &transport{a: http.DefaultTransport}
if _, ok := getRequestCanceler(p); !ok {
t.Fatal("getRequestCanceler failed")
}
p2 := &transport{a: p}
if _, ok := getRequestCanceler(p2); !ok {
t.Fatal("getRequestCanceler(p2) failed")
}
p3 := &transport{}
if _, ok := getRequestCanceler(p3); ok {
t.Fatal("getRequestCanceler(p3)?")
}
}
// --------------------------------------------------------------------