diff --git a/internal/experiment/hhfm/hhfm.go b/internal/experiment/hhfm/hhfm.go index 44d9afa4f1..131cd2a2c7 100644 --- a/internal/experiment/hhfm/hhfm.go +++ b/internal/experiment/hhfm/hhfm.go @@ -274,7 +274,7 @@ func NewRequestEntryList(req *http.Request, headers map[string]string) (out []tr // specific *http.Response instance and its body. func NewHTTPResponse(resp *http.Response, data []byte) (out tracex.HTTPResponse) { out = tracex.HTTPResponse{ - Body: tracex.HTTPBody{Value: string(data)}, + Body: model.ArchivalMaybeBinaryString(data), Code: int64(resp.StatusCode), Headers: make(map[string]tracex.MaybeBinaryValue), HeadersList: []tracex.HTTPHeader{}, diff --git a/internal/experiment/hhfm/hhfm_test.go b/internal/experiment/hhfm/hhfm_test.go index 43897ddaae..59d0b3007c 100644 --- a/internal/experiment/hhfm/hhfm_test.go +++ b/internal/experiment/hhfm/hhfm_test.go @@ -68,7 +68,7 @@ func TestSuccess(t *testing.T) { if request.Failure != nil { t.Fatal("invalid Requests[0].Failure") } - if request.Request.Body.Value != "" { + if request.Request.Body != "" { t.Fatal("invalid Requests[0].Request.Body.Value") } if request.Request.BodyIsTruncated != false { @@ -99,7 +99,7 @@ func TestSuccess(t *testing.T) { if request.Request.URL != ths[0].Address { t.Fatal("invalid Requests[0].Request.URL") } - if len(request.Response.Body.Value) < 1 { + if len(request.Response.Body) < 1 { t.Fatal("invalid Requests[0].Response.Body.Value length") } if request.Response.BodyIsTruncated != false { @@ -181,7 +181,7 @@ func TestCancelledContext(t *testing.T) { if *request.Failure != netxlite.FailureInterrupted { t.Fatal("invalid Requests[0].Failure") } - if request.Request.Body.Value != "" { + if request.Request.Body != "" { t.Fatal("invalid Requests[0].Request.Body.Value") } if request.Request.BodyIsTruncated != false { @@ -212,7 +212,7 @@ func TestCancelledContext(t *testing.T) { if request.Request.URL != ths[0].Address { t.Fatal("invalid Requests[0].Request.URL") } - if len(request.Response.Body.Value) != 0 { + if len(request.Response.Body) != 0 { t.Fatal("invalid Requests[0].Response.Body.Value length") } if request.Response.BodyIsTruncated != false { @@ -811,7 +811,7 @@ func TestNewHTTPResponse(t *testing.T) { data: []byte("deadbeef"), }, wantOut: tracex.HTTPResponse{ - Body: tracex.MaybeBinaryValue{Value: "deadbeef"}, + Body: model.ArchivalMaybeBinaryString("deadbeef"), Code: 200, HeadersList: []tracex.HTTPHeader{{ Key: "Content-Type", @@ -831,7 +831,7 @@ func TestNewHTTPResponse(t *testing.T) { resp: &http.Response{StatusCode: 200}, }, wantOut: tracex.HTTPResponse{ - Body: tracex.MaybeBinaryValue{Value: ""}, + Body: model.ArchivalMaybeBinaryString(""), Code: 200, HeadersList: []tracex.HTTPHeader{}, Headers: map[string]tracex.MaybeBinaryValue{}, diff --git a/internal/experiment/riseupvpn/riseupvpn.go b/internal/experiment/riseupvpn/riseupvpn.go index c0447926f1..c1b7191093 100644 --- a/internal/experiment/riseupvpn/riseupvpn.go +++ b/internal/experiment/riseupvpn/riseupvpn.go @@ -304,7 +304,7 @@ func parseGateways(testKeys *TestKeys) []GatewayV3 { // TODO(bassosimone,cyberta): is it reasonable that we discard // the error when the JSON we fetched cannot be parsed? // See https://github.com/ooni/probe/issues/1432 - eipService, err := DecodeEIP3(requestEntry.Response.Body.Value) + eipService, err := DecodeEIP3(string(requestEntry.Response.Body)) if err == nil { return eipService.Gateways } diff --git a/internal/experiment/riseupvpn/riseupvpn_test.go b/internal/experiment/riseupvpn/riseupvpn_test.go index 98dc8768c9..95b12d8321 100644 --- a/internal/experiment/riseupvpn/riseupvpn_test.go +++ b/internal/experiment/riseupvpn/riseupvpn_test.go @@ -773,13 +773,13 @@ func generateMockGetter(requestResponse map[string]string, responseStatus map[st Failure: failure, Request: tracex.HTTPRequest{ URL: url, - Body: tracex.MaybeBinaryValue{}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, }, Response: tracex.HTTPResponse{ - Body: tracex.HTTPBody{ - Value: responseBody, - }, + Body: model.ArchivalMaybeBinaryString( + responseBody, + ), BodyIsTruncated: false, }}, }, diff --git a/internal/experiment/urlgetter/getter.go b/internal/experiment/urlgetter/getter.go index 2d7931bbec..a62202bf04 100644 --- a/internal/experiment/urlgetter/getter.go +++ b/internal/experiment/urlgetter/getter.go @@ -69,7 +69,7 @@ func (g Getter) Get(ctx context.Context) (TestKeys, error) { if len(tk.Requests) > 0 { // OONI's convention is that the last request appears first tk.HTTPResponseStatus = tk.Requests[0].Response.Code - tk.HTTPResponseBody = tk.Requests[0].Response.Body.Value + tk.HTTPResponseBody = string(tk.Requests[0].Response.Body) tk.HTTPResponseLocations = tk.Requests[0].Response.Locations } tk.TCPConnect = append( diff --git a/internal/experiment/webconnectivity/httpanalysis.go b/internal/experiment/webconnectivity/httpanalysis.go index 6fa3ccb81e..65ea775b30 100644 --- a/internal/experiment/webconnectivity/httpanalysis.go +++ b/internal/experiment/webconnectivity/httpanalysis.go @@ -56,7 +56,7 @@ func HTTPBodyLengthChecks( if response.BodyIsTruncated { return } - measurement := int64(len(response.Body.Value)) + measurement := int64(len(response.Body)) if measurement <= 0 { return } @@ -201,7 +201,7 @@ func HTTPTitleMatch(tk urlgetter.TestKeys, ctrl ControlResponse) (out *bool) { return } control := ctrl.HTTPRequest.Title - measurementBody := response.Body.Value + measurementBody := string(response.Body) measurement := measurexlite.WebGetTitle(measurementBody) if measurement == "" { return diff --git a/internal/experiment/webconnectivity/httpanalysis_test.go b/internal/experiment/webconnectivity/httpanalysis_test.go index ddb1bb1f31..737a969fff 100644 --- a/internal/experiment/webconnectivity/httpanalysis_test.go +++ b/internal/experiment/webconnectivity/httpanalysis_test.go @@ -7,6 +7,7 @@ import ( "github.com/ooni/probe-cli/v3/internal/experiment/urlgetter" "github.com/ooni/probe-cli/v3/internal/experiment/webconnectivity" "github.com/ooni/probe-cli/v3/internal/legacy/tracex" + "github.com/ooni/probe-cli/v3/internal/model" "github.com/ooni/probe-cli/v3/internal/randx" ) @@ -76,9 +77,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) { tk: urlgetter.TestKeys{ Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ - Body: tracex.MaybeBinaryValue{ - Value: randx.Letters(768), - }, + Body: model.ArchivalMaybeBinaryString( + randx.Letters(768), + ), }, }}, }, @@ -95,9 +96,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) { tk: urlgetter.TestKeys{ Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ - Body: tracex.MaybeBinaryValue{ - Value: randx.Letters(768), - }, + Body: model.ArchivalMaybeBinaryString( + randx.Letters(768), + ), }, }}, }, @@ -115,9 +116,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) { tk: urlgetter.TestKeys{ Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ - Body: tracex.MaybeBinaryValue{ - Value: randx.Letters(1024), - }, + Body: model.ArchivalMaybeBinaryString( + randx.Letters(1024), + ), }, }}, }, @@ -135,9 +136,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) { tk: urlgetter.TestKeys{ Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ - Body: tracex.MaybeBinaryValue{ - Value: randx.Letters(8), - }, + Body: model.ArchivalMaybeBinaryString( + randx.Letters(8), + ), }, }}, }, @@ -155,9 +156,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) { tk: urlgetter.TestKeys{ Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ - Body: tracex.MaybeBinaryValue{ - Value: randx.Letters(16), - }, + Body: model.ArchivalMaybeBinaryString( + randx.Letters(16), + ), }, }}, }, @@ -698,7 +699,7 @@ func TestTitleMatch(t *testing.T) { Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ Code: 200, - Body: tracex.MaybeBinaryValue{Value: ""}, + Body: model.ArchivalMaybeBinaryString(""), }, }}, }, @@ -711,7 +712,7 @@ func TestTitleMatch(t *testing.T) { Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ Code: 200, - Body: tracex.MaybeBinaryValue{Value: ""}, + Body: model.ArchivalMaybeBinaryString(""), }, }}, }, @@ -730,8 +731,8 @@ func TestTitleMatch(t *testing.T) { Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ Code: 200, - Body: tracex.MaybeBinaryValue{ - Value: "La community di MSN"}, + Body: model.ArchivalMaybeBinaryString( + "La community di MSN"), }, }}, }, @@ -750,8 +751,8 @@ func TestTitleMatch(t *testing.T) { Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ Code: 200, - Body: tracex.MaybeBinaryValue{ - Value: "La communità di MSN"}, + Body: model.ArchivalMaybeBinaryString( + "La communità di MSN"), }, }}, }, @@ -770,8 +771,8 @@ func TestTitleMatch(t *testing.T) { Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ Code: 200, - Body: tracex.MaybeBinaryValue{ - Value: "" + randx.Letters(1024) + ""}, + Body: model.ArchivalMaybeBinaryString( + "" + randx.Letters(1024) + ""), }, }}, }, @@ -790,8 +791,8 @@ func TestTitleMatch(t *testing.T) { Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ Code: 200, - Body: tracex.MaybeBinaryValue{ - Value: "La commUNity di MSN"}, + Body: model.ArchivalMaybeBinaryString( + "La commUNity di MSN"), }, }}, }, @@ -810,8 +811,8 @@ func TestTitleMatch(t *testing.T) { Requests: []tracex.RequestEntry{{ Response: tracex.HTTPResponse{ Code: 200, - Body: tracex.MaybeBinaryValue{ - Value: "La commUNity di MSN"}, + Body: model.ArchivalMaybeBinaryString( + "La commUNity di MSN"), }, }}, }, diff --git a/internal/experiment/webconnectivitylte/analysishttpdiff.go b/internal/experiment/webconnectivitylte/analysishttpdiff.go index d07fd3c42d..b25a739506 100644 --- a/internal/experiment/webconnectivitylte/analysishttpdiff.go +++ b/internal/experiment/webconnectivitylte/analysishttpdiff.go @@ -91,7 +91,7 @@ func (tk *TestKeys) httpDiffBodyLengthChecks( if response.BodyIsTruncated { return // cannot trust body length in this case } - measurement := int64(len(response.Body.Value)) + measurement := int64(len(response.Body)) if measurement <= 0 { return // no actual length } @@ -230,7 +230,7 @@ func (tk *TestKeys) httpDiffTitleMatch( return } control := ctrl.Title - measurementBody := response.Body.Value + measurementBody := string(response.Body) measurement := measurexlite.WebGetTitle(measurementBody) if control == "" || measurement == "" { return diff --git a/internal/legacy/tracex/archival.go b/internal/legacy/tracex/archival.go index 587663e5ee..e6c20fdce9 100644 --- a/internal/legacy/tracex/archival.go +++ b/internal/legacy/tracex/archival.go @@ -27,7 +27,6 @@ type ( DNSQueryEntry = model.ArchivalDNSLookupResult DNSAnswerEntry = model.ArchivalDNSAnswer TLSHandshake = model.ArchivalTLSOrQUICHandshakeResult - HTTPBody = model.ArchivalHTTPBody HTTPHeader = model.ArchivalHTTPHeader RequestEntry = model.ArchivalHTTPRequestResult HTTPRequest = model.ArchivalHTTPRequest @@ -147,7 +146,7 @@ func newRequestList(begin time.Time, events []Event) (out []RequestEntry) { ev.HTTPResponseHeaders, &entry.Response.HeadersList, &entry.Response.Headers) entry.Response.Code = int64(ev.HTTPStatusCode) entry.Response.Locations = ev.HTTPResponseHeaders.Values("Location") - entry.Response.Body.Value = string(ev.HTTPResponseBody) + entry.Response.Body = model.ArchivalMaybeBinaryString(ev.HTTPResponseBody) entry.Response.BodyIsTruncated = ev.HTTPResponseBodyIsTruncated entry.Failure = ev.Err.ToFailure() out = append(out, entry) diff --git a/internal/legacy/tracex/archival_test.go b/internal/legacy/tracex/archival_test.go index 4186df9df5..28274f08bc 100644 --- a/internal/legacy/tracex/archival_test.go +++ b/internal/legacy/tracex/archival_test.go @@ -191,9 +191,7 @@ func TestNewRequestList(t *testing.T) { T: 0.02, }, { Request: HTTPRequest{ - Body: MaybeBinaryValue{ - Value: "", - }, + Body: model.ArchivalMaybeBinaryString(""), HeadersList: []HTTPHeader{{ Key: "User-Agent", Value: MaybeBinaryValue{ @@ -207,9 +205,7 @@ func TestNewRequestList(t *testing.T) { URL: "https://www.example.com/submit", }, Response: HTTPResponse{ - Body: MaybeBinaryValue{ - Value: "{}", - }, + Body: model.ArchivalMaybeBinaryString("{}"), Code: 200, HeadersList: []HTTPHeader{{ Key: "Server", diff --git a/internal/measurexlite/http.go b/internal/measurexlite/http.go index 680b8ab80e..6a21da36a6 100644 --- a/internal/measurexlite/http.go +++ b/internal/measurexlite/http.go @@ -52,7 +52,7 @@ func NewArchivalHTTPRequestResult(index int64, started time.Duration, network, a ALPN: alpn, Failure: NewFailure(err), Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: newHTTPRequestHeaderList(req), Headers: newHTTPRequestHeaderMap(req), @@ -62,7 +62,7 @@ func NewArchivalHTTPRequestResult(index int64, started time.Duration, network, a URL: httpRequestURL(req), }, Response: model.ArchivalHTTPResponse{ - Body: httpResponseBody(body), + Body: model.ArchivalMaybeBinaryString(body), BodyIsTruncated: httpResponseBodyIsTruncated(body, maxRespBodySize), Code: httpResponseStatusCode(resp), HeadersList: newHTTPResponseHeaderList(resp), @@ -112,14 +112,6 @@ func httpRequestURL(req *http.Request) (out string) { return } -// httpResponseBody returns the response body, if possible, or an empty body. -func httpResponseBody(body []byte) (out model.ArchivalMaybeBinaryData) { - if body != nil { - out.Value = string(body) - } - return -} - // httpResponseBodyIsTruncated determines whether the body is truncated (if possible) func httpResponseBodyIsTruncated(body []byte, maxSnapSize int64) (out bool) { if len(body) > 0 && maxSnapSize > 0 { diff --git a/internal/measurexlite/http_test.go b/internal/measurexlite/http_test.go index a874299028..6c41ff1a21 100644 --- a/internal/measurexlite/http_test.go +++ b/internal/measurexlite/http_test.go @@ -58,7 +58,7 @@ func TestNewArchivalHTTPRequestResult(t *testing.T) { ALPN: "", Failure: nil, Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: []model.ArchivalHTTPHeader{}, Headers: map[string]model.ArchivalMaybeBinaryData{}, @@ -68,7 +68,7 @@ func TestNewArchivalHTTPRequestResult(t *testing.T) { URL: "", }, Response: model.ArchivalHTTPResponse{ - Body: model.ArchivalMaybeBinaryData{}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, Code: 0, HeadersList: []model.ArchivalHTTPHeader{}, @@ -117,7 +117,7 @@ func TestNewArchivalHTTPRequestResult(t *testing.T) { return &s }(), Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: []model.ArchivalHTTPHeader{{ Key: "Accept", @@ -140,7 +140,7 @@ func TestNewArchivalHTTPRequestResult(t *testing.T) { URL: "http://dns.google/", }, Response: model.ArchivalHTTPResponse{ - Body: model.ArchivalMaybeBinaryData{}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, Code: 0, HeadersList: []model.ArchivalHTTPHeader{}, @@ -192,7 +192,7 @@ func TestNewArchivalHTTPRequestResult(t *testing.T) { ALPN: "h3", Failure: nil, Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: []model.ArchivalHTTPHeader{{ Key: "Accept", @@ -215,9 +215,9 @@ func TestNewArchivalHTTPRequestResult(t *testing.T) { URL: "https://dns.google/", }, Response: model.ArchivalHTTPResponse{ - Body: model.ArchivalMaybeBinaryData{ - Value: string(testingx.HTTPBlockpage451), - }, + Body: model.ArchivalMaybeBinaryString( + testingx.HTTPBlockpage451, + ), BodyIsTruncated: false, Code: 200, HeadersList: []model.ArchivalHTTPHeader{{ @@ -290,7 +290,7 @@ func TestNewArchivalHTTPRequestResult(t *testing.T) { ALPN: "h3", Failure: nil, Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: []model.ArchivalHTTPHeader{{ Key: "Accept", @@ -313,9 +313,7 @@ func TestNewArchivalHTTPRequestResult(t *testing.T) { URL: "https://dns.google/", }, Response: model.ArchivalHTTPResponse{ - Body: model.ArchivalMaybeBinaryData{ - Value: "", - }, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, Code: 302, HeadersList: []model.ArchivalHTTPHeader{{ diff --git a/internal/model/archival.go b/internal/model/archival.go index 88b675a819..56f8eb35f2 100644 --- a/internal/model/archival.go +++ b/internal/model/archival.go @@ -323,7 +323,7 @@ type ArchivalHTTPRequestResult struct { // Headers are a map in Web Connectivity data format but // we have added support for a list since January 2020. type ArchivalHTTPRequest struct { - Body ArchivalHTTPBody `json:"body"` + Body ArchivalMaybeBinaryString `json:"body"` BodyIsTruncated bool `json:"body_is_truncated"` HeadersList []ArchivalHTTPHeader `json:"headers_list"` Headers map[string]ArchivalMaybeBinaryData `json:"headers"` @@ -338,7 +338,7 @@ type ArchivalHTTPRequest struct { // Headers are a map in Web Connectivity data format but // we have added support for a list since January 2020. type ArchivalHTTPResponse struct { - Body ArchivalHTTPBody `json:"body"` + Body ArchivalMaybeBinaryString `json:"body"` BodyIsTruncated bool `json:"body_is_truncated"` Code int64 `json:"code"` HeadersList []ArchivalHTTPHeader `json:"headers_list"` @@ -349,13 +349,6 @@ type ArchivalHTTPResponse struct { Locations []string `json:"-"` } -// ArchivalHTTPBody is an HTTP body. As an implementation note, this type must -// be an alias for the MaybeBinaryValue type, otherwise the specific serialisation -// mechanism implemented by MaybeBinaryValue is not working. -// -// QUIRK: it's quite fragile we must use an alias here--more robust solution? -type ArchivalHTTPBody = ArchivalMaybeBinaryData - // ArchivalHTTPHeader is a single HTTP header. type ArchivalHTTPHeader struct { Key string diff --git a/internal/model/archival_test.go b/internal/model/archival_test.go index f09c182bec..5b1cd37450 100644 --- a/internal/model/archival_test.go +++ b/internal/model/archival_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/ooni/probe-cli/v3/internal/model" "github.com/ooni/probe-cli/v3/internal/netxlite" - "github.com/ooni/probe-cli/v3/internal/testingx" ) func TestArchivalExtSpec(t *testing.T) { @@ -295,6 +294,14 @@ func TestArchivalBinaryData(t *testing.T) { } func TestArchivalMaybeBinaryString(t *testing.T) { + t.Run("Supports assignment from a nil byte array", func(t *testing.T) { + var data []byte = nil // explicit + casted := model.ArchivalMaybeBinaryString(data) + if casted != "" { + t.Fatal("unexpected value") + } + }) + // This test verifies that we correctly serialize a string to JSON by // producing "" | {"format":"base64","data":""} t.Run("MarshalJSON", func(t *testing.T) { @@ -788,28 +795,6 @@ func TestHTTPHeader(t *testing.T) { }) } -func TestHTTPBody(t *testing.T) { - // Implementation note: the content is always going to be the same - // even if we modify the implementation to become: - // - // type ArchivalHTTPBody ArchivalMaybeBinaryData - // - // instead of the correct: - // - // type ArchivalHTTPBody = ArchivalMaybeBinaryData - // - // However, cmp.Diff also takes into account the data type. Hence, if - // we make a mistake and apply the above change (which will in turn - // break correct JSON serialization), the this test will fail. - var body model.ArchivalHTTPBody - ff := &testingx.FakeFiller{} - ff.Fill(&body) - data := model.ArchivalMaybeBinaryData(body) - if diff := cmp.Diff(body, data); diff != "" { - t.Fatal(diff) - } -} - // This test ensures that ArchivalDNSLookupResult is WAI func TestArchivalDNSLookupResult(t *testing.T) { @@ -1463,7 +1448,7 @@ func TestArchivalHTTPRequestResult(t *testing.T) { ALPN: "h2", Failure: nil, Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{Value: ""}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: []model.ArchivalHTTPHeader{{ Key: "Accept", @@ -1490,9 +1475,9 @@ func TestArchivalHTTPRequestResult(t *testing.T) { URL: "https://www.example.com/", }, Response: model.ArchivalHTTPResponse{ - Body: model.ArchivalMaybeBinaryData{ - Value: "Bonsoir, Elliot!", - }, + Body: model.ArchivalMaybeBinaryString( + "Bonsoir, Elliot!", + ), BodyIsTruncated: false, Code: 200, HeadersList: []model.ArchivalHTTPHeader{{ @@ -1529,7 +1514,7 @@ func TestArchivalHTTPRequestResult(t *testing.T) { return &s })(), Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{Value: ""}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: []model.ArchivalHTTPHeader{{ Key: "Accept", @@ -1556,7 +1541,7 @@ func TestArchivalHTTPRequestResult(t *testing.T) { URL: "https://www.example.com/", }, Response: model.ArchivalHTTPResponse{ - Body: model.ArchivalMaybeBinaryData{}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, Code: 0, HeadersList: []model.ArchivalHTTPHeader{}, @@ -1585,7 +1570,7 @@ func TestArchivalHTTPRequestResult(t *testing.T) { ALPN: "h2", Failure: nil, Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{Value: ""}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: []model.ArchivalHTTPHeader{{ Key: "Accept", @@ -1623,9 +1608,9 @@ func TestArchivalHTTPRequestResult(t *testing.T) { URL: "https://www.example.com/", }, Response: model.ArchivalHTTPResponse{ - Body: model.ArchivalMaybeBinaryData{ - Value: string(archivalBinaryInput[:77]), - }, + Body: model.ArchivalMaybeBinaryString( + archivalBinaryInput[:77], + ), BodyIsTruncated: false, Code: 200, HeadersList: []model.ArchivalHTTPHeader{{ @@ -1679,7 +1664,7 @@ func TestArchivalHTTPRequestResult(t *testing.T) { ALPN: "h2", Failure: nil, Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{Value: ""}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: []model.ArchivalHTTPHeader{{ Key: "Accept", @@ -1730,9 +1715,9 @@ func TestArchivalHTTPRequestResult(t *testing.T) { URL: "https://www.example.com/", }, Response: model.ArchivalHTTPResponse{ - Body: model.ArchivalMaybeBinaryData{ - Value: "Your address is 130.192.91.211 and 2606:2800:220:1:248:1893:25c8:1946 and you have endpoints [2606:2800:220:1:248:1893:25c8:1946]:5222 and 130.192.91.211:443. You're welcome.", - }, + Body: model.ArchivalMaybeBinaryString( + "Your address is 130.192.91.211 and 2606:2800:220:1:248:1893:25c8:1946 and you have endpoints [2606:2800:220:1:248:1893:25c8:1946]:5222 and 130.192.91.211:443. You're welcome.", + ), BodyIsTruncated: false, Code: 200, HeadersList: []model.ArchivalHTTPHeader{{ @@ -1843,7 +1828,7 @@ func TestArchivalHTTPRequestResult(t *testing.T) { ALPN: "h2", Failure: nil, Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{Value: ""}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: []model.ArchivalHTTPHeader{{ Key: "Accept", @@ -1870,9 +1855,9 @@ func TestArchivalHTTPRequestResult(t *testing.T) { URL: "https://www.example.com/", }, Response: model.ArchivalHTTPResponse{ - Body: model.ArchivalMaybeBinaryData{ - Value: "Bonsoir, Elliot!", - }, + Body: model.ArchivalMaybeBinaryString( + "Bonsoir, Elliot!", + ), BodyIsTruncated: false, Code: 200, HeadersList: []model.ArchivalHTTPHeader{{ @@ -1906,7 +1891,7 @@ func TestArchivalHTTPRequestResult(t *testing.T) { return &s })(), Request: model.ArchivalHTTPRequest{ - Body: model.ArchivalMaybeBinaryData{Value: ""}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, HeadersList: []model.ArchivalHTTPHeader{{ Key: "Accept", @@ -1933,7 +1918,7 @@ func TestArchivalHTTPRequestResult(t *testing.T) { URL: "https://www.example.com/", }, Response: model.ArchivalHTTPResponse{ - Body: model.ArchivalMaybeBinaryData{}, + Body: model.ArchivalMaybeBinaryString(""), BodyIsTruncated: false, Code: 0, HeadersList: []model.ArchivalHTTPHeader{},