diff --git a/api/agent/protocol/factory.go b/api/agent/protocol/factory.go index a9132dcfb..db87d4837 100644 --- a/api/agent/protocol/factory.go +++ b/api/agent/protocol/factory.go @@ -64,7 +64,7 @@ func (ci callInfoImpl) Input() io.Reader { } func (ci callInfoImpl) ProtocolType() string { - return "http" + return ci.call.Type } // Request basically just for the http format, since that's the only that makes sense to have the full request as is diff --git a/api/agent/protocol/json_test.go b/api/agent/protocol/json_test.go index 4805fb21d..1a8764089 100644 --- a/api/agent/protocol/json_test.go +++ b/api/agent/protocol/json_test.go @@ -48,7 +48,7 @@ func TestJSONProtocolwriteJSONInputRequestWithData(t *testing.T) { rDataBefore := RequestData{A: "a"} req := setupRequest(rDataBefore) r, w := io.Pipe() - call := &models.Call{} + call := &models.Call{Type: "json"} ci := &callInfoImpl{call, req} proto := JSONProtocol{w, r} go func() { @@ -78,12 +78,16 @@ func TestJSONProtocolwriteJSONInputRequestWithData(t *testing.T) { t.Errorf("Request data assertion mismatch: expected: %s, got %s", rDataBefore.A, rDataAfter.A) } + if incomingReq.Protocol.Type != call.Type { + t.Errorf("Call protocol type assertion mismatch: expected: %s, got %s", + call.Type, incomingReq.Protocol.Type) + } } func TestJSONProtocolwriteJSONInputRequestWithoutData(t *testing.T) { req := setupRequest(nil) - call := &models.Call{} + call := &models.Call{Type: "json"} r, w := io.Pipe() ci := &callInfoImpl{call, req} proto := JSONProtocol{w, r} @@ -119,7 +123,7 @@ func TestJSONProtocolwriteJSONInputRequestWithQuery(t *testing.T) { req := setupRequest(nil) r, w := io.Pipe() - call := &models.Call{} + call := &models.Call{Type: "json"} ci := &callInfoImpl{call, req} proto := JSONProtocol{w, r} go func() {