From 46fce591a62e89fad0adb59eb905eafde1d3d2f8 Mon Sep 17 00:00:00 2001
From: a <a@tuxpa.in>
Date: Thu, 23 Nov 2023 23:32:09 -0600
Subject: [PATCH] no test no bug

---
 contrib/codecs/http/codec.go               |  2 +-
 contrib/codecs/http/http_test.go           | 34 ---------------------
 contrib/codecs/websocket/websocket_test.go | 35 ----------------------
 pkg/jsonrpc/peer.go                        |  2 +-
 4 files changed, 2 insertions(+), 71 deletions(-)

diff --git a/contrib/codecs/http/codec.go b/contrib/codecs/http/codec.go
index b3fb38d..ae14d5e 100644
--- a/contrib/codecs/http/codec.go
+++ b/contrib/codecs/http/codec.go
@@ -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
diff --git a/contrib/codecs/http/http_test.go b/contrib/codecs/http/http_test.go
index c13b8ac..1e8c456 100644
--- a/contrib/codecs/http/http_test.go
+++ b/contrib/codecs/http/http_test.go
@@ -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})
diff --git a/contrib/codecs/websocket/websocket_test.go b/contrib/codecs/websocket/websocket_test.go
index b5e4497..04981d0 100644
--- a/contrib/codecs/websocket/websocket_test.go
+++ b/contrib/codecs/websocket/websocket_test.go
@@ -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()
diff --git a/pkg/jsonrpc/peer.go b/pkg/jsonrpc/peer.go
index 36bf95f..b89d860 100644
--- a/pkg/jsonrpc/peer.go
+++ b/pkg/jsonrpc/peer.go
@@ -12,5 +12,5 @@ type PeerInfo struct {
 	RemoteAddr string
 
 	// Additional information for HTTP and WebSocket connections.
-	HTTP *http.Request
+	HTTP *http.Request `json:"-"`
 }
-- 
GitLab