From d08ce0281c64f1d6df52c8205c78add50339121a Mon Sep 17 00:00:00 2001 From: Norbel AMBANUMBEN Date: Mon, 8 Apr 2024 15:56:12 +0100 Subject: [PATCH] fix(oonimkall.HTTPRequest): `URL` => `Url` to fix iOS (#1545) Closes: https://github.com/ooni/probe/issues/2701 --------- Co-authored-by: Simone Basso --- pkg/oonimkall/httpx.go | 8 +++++--- pkg/oonimkall/httpx_test.go | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/oonimkall/httpx.go b/pkg/oonimkall/httpx.go index bc5d6f33c..d24f75691 100644 --- a/pkg/oonimkall/httpx.go +++ b/pkg/oonimkall/httpx.go @@ -29,8 +29,10 @@ type HTTPRequest struct { // Method is the MANDATORY request method. Method string - // URL is the MANDATORY request URL. - URL string + // Url is the MANDATORY request URL. + // + // Note: this field MUST be named "Url" not "URL"; see https://github.com/ooni/probe/issues/2701. + Url string } // HTTPResponse is an HTTP response. @@ -54,7 +56,7 @@ func (sess *Session) HTTPDo(ctx *Context, jreq *HTTPRequest) (*HTTPResponse, err func (sess *Session) httpDoLocked(ctx *Context, jreq *HTTPRequest) (*HTTPResponse, error) { clnt := sess.sessp.DefaultHTTPClient() - req, err := http.NewRequestWithContext(ctx.ctx, jreq.Method, jreq.URL, nil) + req, err := http.NewRequestWithContext(ctx.ctx, jreq.Method, jreq.Url, nil) if err != nil { return nil, err } diff --git a/pkg/oonimkall/httpx_test.go b/pkg/oonimkall/httpx_test.go index 98c0d7a4d..f8f6666d6 100644 --- a/pkg/oonimkall/httpx_test.go +++ b/pkg/oonimkall/httpx_test.go @@ -29,7 +29,7 @@ func TestSessionHTTPDo(t *testing.T) { req := &oonimkall.HTTPRequest{ Method: "GET", - URL: server.URL, + Url: server.URL, } sess, err := NewSessionForTesting() @@ -55,7 +55,7 @@ func TestSessionHTTPDo(t *testing.T) { req := &oonimkall.HTTPRequest{ Method: "GET", - URL: "\t", // this URL is invalid + Url: "\t", // this URL is invalid } resp, err := sess.HTTPDo(sess.NewContext(), req) @@ -75,7 +75,7 @@ func TestSessionHTTPDo(t *testing.T) { req := &oonimkall.HTTPRequest{ Method: "GET", - URL: server.URL, + Url: server.URL, } sess, err := NewSessionForTesting() @@ -107,7 +107,7 @@ func TestSessionHTTPDo(t *testing.T) { req := &oonimkall.HTTPRequest{ Method: "GET", - URL: URL.String(), + Url: URL.String(), } sess, err := NewSessionForTesting() @@ -142,7 +142,7 @@ func TestSessionHTTPDo(t *testing.T) { req := &oonimkall.HTTPRequest{ Method: "GET", - URL: server.URL, + Url: server.URL, } sess, err := NewSessionForTesting()