Skip to content

Commit

Permalink
do not follow redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Mornini committed Aug 16, 2017
1 parent a81c617 commit fd0e9ae
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
16 changes: 12 additions & 4 deletions 02-spec-file-processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,20 @@ func specFileProcessor(context context) {
context.Substitutions = map[string]string{}

if context.SkipTLSVerification {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
context.HTTPClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
context.HTTPClient = &http.Client{Transport: tr}
} else {
context.HTTPClient = &http.Client{}
context.HTTPClient = &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
}

specTripletIterator(&context)
Expand Down
23 changes: 23 additions & 0 deletions example-do-not-follow-redirect.htsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
> GET https://jigsaw.w3.org/HTTP/300/302.html HTTP/1.1
>

< HTTP/1.1 302 Found
< Content-Length: 389
< Content-Type: text/html;charset=ISO-8859-1
< Date: ⧆⧆:date⧆
< Location: https://jigsaw.w3.org/HTTP/300/Overview.html
< Public-Key-Pins: pin-sha256="cN0QSpPIkuwpT6iP2YjEo1bEwGpH/yiUn6yhdy+HNto="; pin-sha256="WGJkyYjx1QMdMe0UqlyOKXtydPDVrk7sl2fV+nNm1r4="; pin-sha256="LrKdTxZLRTvyHM4/atX2nquX9BeHRZMCxg3cf4rhc2I="; max-age=864000
< Server: Jigsaw/2.3.0-beta2
< Strict-Transport-Security: max-age=15552015; includeSubDomains; preload
< X-Frame-Options: deny
< X-Xss-Protection: 1; mode=block
<
< <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
< "http://www.w3.org/TR/html4/loose.dtd">
< <html>
< <head>
< <title>Moved</title>
< </head>
< <body>
< <P>This resources has moved, click on the link if your browser doesn't support automatic redirection<BR><A HREF="http://jigsaw.w3.org/HTTP/300/Overview.html">http://jigsaw.w3.org/HTTP/300/Overview.html</A></body>
< </html>
2 changes: 1 addition & 1 deletion example-insecure.htsf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
< Date: ⧆⧆:date⧆
< Etag: ⧆⧆.+⧆
< Last-Modified: ⧆⧆:date⧆
< Server: nginx/1.10.0 (Ubuntu)
< Server: nginx/1.10.3 (Ubuntu)
<
< <!DOCTYPE html>
< <html>
Expand Down
2 changes: 2 additions & 0 deletions run-http-specs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ time (
example-sleep.htsf || exit 1

http-spec -skip-tls-verification example-insecure.htsf || exit 1

http-spec example-do-not-follow-redirect.htsf || exit 1
) || exit 1

echo
Expand Down

0 comments on commit fd0e9ae

Please sign in to comment.