@@ -30,7 +30,7 @@ import (
3030
3131 "github.com/andybalholm/brotli"
3232 "github.com/klauspost/compress/zstd"
33- "github.com/mccutchen/go-httpbin/httpbin"
33+ "github.com/mccutchen/go-httpbin/v2/ httpbin"
3434 "github.com/sirupsen/logrus"
3535 "github.com/stretchr/testify/assert"
3636 "github.com/stretchr/testify/require"
@@ -274,11 +274,11 @@ func TestRequest(t *testing.T) {
274274 http .Redirect (w , r , sr ("HTTPBIN_URL/post" ), http .StatusPermanentRedirect )
275275 }))
276276 _ , err := rt .RunString (sr (`
277- var res = http.post("HTTPBIN_URL/post-redirect", "pesho", {redirects: 1});
277+ var res = http.post("HTTPBIN_URL/post-redirect", "pesho", {redirects: 1, headers: {"Content-Type": "text"} });
278278
279279 if (res.status != 200) { throw new Error("wrong status: " + res.status) }
280280 if (res.url != "HTTPBIN_URL/post") { throw new Error("incorrect URL: " + res.url) }
281- if (res.json().data != "pesho ") { throw new Error("incorrect data : " + res.json().data) }
281+ if (res.json().data != "data:text;base64,cGVzaG8= ") { throw new Error("incorrect data : " + res.json().data) }
282282 ` ))
283283 assert .NoError (t , err )
284284 })
@@ -1074,13 +1074,13 @@ func TestRequest(t *testing.T) {
10741074 })
10751075
10761076 t .Run ("name/template" , func (t * testing.T ) {
1077- _ , err := rt .RunString ("http.get(http.url`" + sr (`HTTPBIN_URL/anything /${1+1}` ) + "`);" )
1077+ _ , err := rt .RunString ("http.get(http.url`" + sr (`HTTPBIN_URL/anythingwrong /${1+1}` ) + "`);" )
10781078 assert .NoError (t , err )
1079- // There's no /anything endpoint in the go-httpbin library we're using, hence the 404,
1079+ // There's no /anythingwrong endpoint in the go-httpbin library we're using, hence the 404,
10801080 // but it doesn't matter for this test.
10811081 //
10821082 // Setting name will overwrite both name and url tags
1083- assertRequestMetricsEmitted (t , metrics .GetBufferedSamples (samples ), "GET" , sr ("HTTPBIN_URL/anything /${}" ), 404 , "" )
1083+ assertRequestMetricsEmitted (t , metrics .GetBufferedSamples (samples ), "GET" , sr ("HTTPBIN_URL/anythingwrong /${}" ), 404 , "" )
10841084 })
10851085
10861086 t .Run ("object" , func (t * testing.T ) {
@@ -1169,7 +1169,6 @@ func TestRequest(t *testing.T) {
11691169 var res = http.head("HTTPBIN_URL/get?a=1&b=2", {headers: {"X-We-Want-This": "value"}});
11701170 if (res.status != 200) { throw new Error("wrong status: " + res.status); }
11711171 if (res.body.length != 0) { throw new Error("HEAD responses shouldn't have a body"); }
1172- if (!res.headers["Content-Length"]) { throw new Error("Missing or invalid Content-Length header!"); }
11731172 if (res.request.headers["X-We-Want-This"] != "value") { throw new Error("Missing or invalid X-We-Want-This header!"); }
11741173 ` ))
11751174 assert .NoError (t , err )
@@ -1212,7 +1211,8 @@ func TestRequest(t *testing.T) {
12121211 _ , err := rt .RunString (fmt .Sprintf (sr (`
12131212 var res = http.%s("HTTPBIN_URL/%s", "data", {headers: {"X-We-Want-This": "value"}});
12141213 if (res.status != 200) { throw new Error("wrong status: " + res.status); }
1215- if (res.json().data != "data") { throw new Error("wrong data: " + res.json().data); }
1214+ var expectedData = "data:application/octet-stream;base64,ZGF0YQ=="
1215+ if (res.json().data != expectedData) { throw new Error("wrong data: " + res.json().data); }
12161216 if (res.json().headers["Content-Type"]) { throw new Error("content type set: " + res.json().headers["Content-Type"]); }
12171217 if (res.request.headers["X-We-Want-This"] != "value") { throw new Error("Missing or invalid X-We-Want-This header!"); }
12181218 ` ), fn , strings .ToLower (method )))
@@ -2217,13 +2217,13 @@ func TestDigestAuthWithBody(t *testing.T) {
22172217 state .Options .Throw = null .BoolFrom (true )
22182218 state .Options .HTTPDebug = null .StringFrom ("full" )
22192219
2220- tb .Mux .HandleFunc ("/digest-auth-with-post/" , func (w http.ResponseWriter , r * http.Request ) {
2220+ tb .Mux .HandleFunc ("/digest-auth-with-post/{qop}/{user}/{password} " , http . HandlerFunc ( func (w http.ResponseWriter , r * http.Request ) {
22212221 require .Equal (t , http .MethodPost , r .Method )
22222222 body , err := io .ReadAll (r .Body )
22232223 require .NoError (t , err )
22242224 require .Equal (t , "super secret body" , string (body ))
22252225 httpbin .New ().DigestAuth (w , r ) // this doesn't read the body
2226- })
2226+ }))
22272227
22282228 urlWithCreds := tb .Replacer .Replace (
22292229 "http://testuser:testpwd@HTTPBIN_IP:HTTPBIN_PORT/digest-auth-with-post/auth/testuser/testpwd" ,
0 commit comments