@@ -479,15 +479,15 @@ func (this *SignerSuite) TestAddsLinkHeaders() {
479
479
Sign : & util.URLPattern {[]string {"https" }, "" , this .httpsHost (), stringPtr ("/amp/.*" ), []string {}, stringPtr ("" ), false , 2000 , nil }}}
480
480
this .fakeHandler = func (resp http.ResponseWriter , req * http.Request ) {
481
481
resp .Header ().Set ("Content-Type" , "text/html; charset=utf-8" )
482
- resp .Write ([]byte (" <html amp><head><link rel=stylesheet href=foo><script src=bar>" ))
482
+ resp .Write ([]byte (` <html amp><head><link rel=stylesheet href=foo><script src=bar></script><link rel=preload as=image href=baz imagesizes="100vw" imagesrcset="qux">` ))
483
483
}
484
484
target := "/priv/doc?sign=" + url .QueryEscape (this .httpsURL ()+ fakePath )
485
485
resp := pkgt .NewRequest (this .T (), this .new (urlSets ), target ).SetHeaders ("" , header ).Do ()
486
486
this .Assert ().Equal (http .StatusOK , resp .StatusCode , "incorrect status: %#v" , resp )
487
487
488
488
exchange , err := signedexchange .ReadExchange (resp .Body )
489
489
this .Require ().NoError (err )
490
- this .Assert ().Equal ("<foo>;rel=preload;as=style,<bar>;rel=preload;as=script" , exchange .ResponseHeaders .Get ("Link" ))
490
+ this .Assert ().Equal ("<foo>;rel=preload;as=style,<bar>;rel=preload;as=script,<baz>;rel=preload;as=image;imagesizes= \" 100vw \" ;imagesrcset= \" qux \" " , exchange .ResponseHeaders .Get ("Link" ))
491
491
}
492
492
493
493
func (this * SignerSuite ) TestEscapesLinkHeaders () {
@@ -500,15 +500,15 @@ func (this *SignerSuite) TestEscapesLinkHeaders() {
500
500
// However, it would be nice to limit the impact that could be
501
501
// caused by transformation of an invalid AMP, e.g. on a
502
502
// same-origin impression.
503
- resp .Write ([]byte (`<html amp><head><script src="https://foo.com/a,b>c?d>e|f">` ))
503
+ resp .Write ([]byte (`<html amp><head><script src="https://foo.com/a,b>c?d>e|f"></script><link rel=preload as=image href=bar imagesrcset='test"ing'> ` ))
504
504
}
505
505
target := "/priv/doc?sign=" + url .QueryEscape (this .httpsURL ()+ fakePath )
506
506
resp := pkgt .NewRequest (this .T (), this .new (urlSets ), target ).SetHeaders ("" , header ).Do ()
507
507
this .Assert ().Equal (http .StatusOK , resp .StatusCode , "incorrect status: %#v" , resp )
508
508
509
509
exchange , err := signedexchange .ReadExchange (resp .Body )
510
510
this .Require ().NoError (err )
511
- this .Assert ().Equal ("<https://foo.com/a,b%3Ec?d%3Ee%7Cf>;rel=preload;as=script" , exchange .ResponseHeaders .Get ("Link" ))
511
+ this .Assert ().Equal ("<https://foo.com/a,b%3Ec?d%3Ee%7Cf>;rel=preload;as=script,<bar>;rel=preload;as=image;imagesrcset= \" test \\ \" ing \" " , exchange .ResponseHeaders .Get ("Link" ))
512
512
}
513
513
514
514
func (this * SignerSuite ) TestRemovesHopByHopHeaders () {
0 commit comments