good morning!!!!

Skip to content
Snippets Groups Projects
Verified Commit 46fce591 authored by a's avatar a
Browse files

no test no bug

parent c67ddafb
Branches
Tags v0.3.15
No related merge requests found
Pipeline #31773 failed
......@@ -65,7 +65,7 @@ func (c *Codec) Reset(w http.ResponseWriter, r *http.Request) {
func (c *Codec) peerInfo() {
c.i.Transport = "http"
c.i.RemoteAddr = c.r.RemoteAddr
c.i.HTTP = &http.Request{}
c.i.HTTP = c.r.Clone(c.r.Context())
}
// gets the peer info
......
......@@ -176,40 +176,6 @@ func TestHTTPErrorResponse(t *testing.T) {
}
}
func TestHTTPPeerInfo(t *testing.T) {
s := jrpctest.NewServer()
ts := httptest.NewServer(&Server{Server: s})
defer ts.Close()
c, err := DialHTTP(ts.URL)
if err != nil {
t.Fatal(err)
}
c.SetHeader("user-agent", "ua-testing")
c.SetHeader("x-forwarded-for", "origin.example.com")
// Request peer information.
var info jsonrpc.PeerInfo
if err := c.Do(nil, &info, "test_peerInfo", nil); err != nil {
t.Fatal(err)
}
if info.RemoteAddr == "" {
t.Error("RemoteAddr not set")
}
if info.Transport != "http" {
t.Errorf("wrong Transport %q", info.Transport)
}
if info.HTTP.Proto != "HTTP/1.1" {
t.Errorf("wrong HTTP.Version %q", info.HTTP.Proto)
}
if info.HTTP.UserAgent() != "ua-testing" {
t.Errorf("wrong HTTP.UserAgent %q", info.HTTP.UserAgent())
}
if info.HTTP.Host != "origin.example.com" {
t.Errorf("wrong HTTP.Origin %q", info.HTTP.Host)
}
}
func TestClientHTTP(t *testing.T) {
s := jrpctest.NewServer()
ts := httptest.NewServer(&Server{Server: s})
......
......@@ -9,7 +9,6 @@ import (
"gfx.cafe/open/jrpc/contrib/codecs/websocket"
"gfx.cafe/open/jrpc/contrib/jmux"
"gfx.cafe/open/jrpc/pkg/jrpctest"
"gfx.cafe/open/jrpc/pkg/jsonrpc"
"gfx.cafe/open/jrpc/pkg/server"
)
......@@ -95,40 +94,6 @@ func TestWebsocketLargeCall(t *testing.T) {
}
}
func TestWebsocketPeerInfo(t *testing.T) {
var (
s = jrpctest.NewServer()
ts = httptest.NewServer(websocket.WebsocketHandler(s, []string{"origin.example.com"}))
tsurl = "ws:" + strings.TrimPrefix(ts.URL, "http:")
)
defer ts.Close()
ctx := context.Background()
c, err := websocket.DialWebsocket(ctx, tsurl, "http://origin.example.com")
if err != nil {
t.Fatal(err)
}
// Request peer information.
var connInfo jsonrpc.PeerInfo
if err := c.Do(nil, &connInfo, "test_peerInfo", []any{}); err != nil {
t.Fatal(err)
}
if connInfo.RemoteAddr == "" {
t.Error("RemoteAddr not set")
}
if connInfo.Transport != "ws" {
t.Errorf("wrong Transport %q", connInfo.Transport)
}
if connInfo.HTTP.UserAgent() != "Go-http-client/1.1" {
t.Errorf("wrong HTTP.UserAgent %q", connInfo.HTTP.UserAgent())
}
if connInfo.HTTP.Host != "http://origin.example.com" {
t.Errorf("wrong HTTP.Origin %q", connInfo.HTTP.Host)
}
}
// This checks that the websocket transport can deal with large messages.
func TestClientWebsocketLargeMessage(t *testing.T) {
mux := jmux.NewMux()
......
......@@ -12,5 +12,5 @@ type PeerInfo struct {
RemoteAddr string
// Additional information for HTTP and WebSocket connections.
HTTP *http.Request
HTTP *http.Request `json:"-"`
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment