File tree Expand file tree Collapse file tree 4 files changed +12
-5
lines changed
Expand file tree Collapse file tree 4 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 11# Saber
22
3- [ ![ Latest Version] ( https://img.shields.io/github/release/swlib/saber.svg?style=flat-square )] ( https://github.com/swlib/saber/releases )
3+ [ ![ Latest Version] ( https://img.shields.io/github/release/swlib/saber.svg )] ( https://github.com/swlib/saber/releases )
44[ ![ PHPUnit for Saber] ( https://github.com/swlib/saber/workflows/PHPUnit%20for%20Saber/badge.svg )] ( https://github.com/swlib/saber/actions )
55[ ![ Php Version] ( https://img.shields.io/badge/php-%3E=7.1-brightgreen.svg?maxAge=2592000 )] ( https://secure.php.net/ )
66[ ![ Swoole Version] ( https://img.shields.io/badge/swoole-%3E=2.1.2-brightgreen.svg?maxAge=2592000 )] ( https://github.com/swoole/swoole-src )
Original file line number Diff line number Diff line change 11# Saber
22
3- [ ![ Latest Version] ( https://img.shields.io/github/release/swlib/saber.svg?style=flat-square )] ( https://github.com/swlib/saber/releases )
3+ [ ![ Latest Version] ( https://img.shields.io/github/release/swlib/saber.svg )] ( https://github.com/swlib/saber/releases )
44[ ![ PHPUnit for Saber] ( https://github.com/swlib/saber/workflows/PHPUnit%20for%20Saber/badge.svg )] ( https://github.com/swlib/saber/actions )
55[ ![ Php Version] ( https://img.shields.io/badge/php-%3E=7.1-brightgreen.svg?maxAge=2592000 )] ( https://secure.php.net/ )
66[ ![ Swoole Version] ( https://img.shields.io/badge/swoole-%3E=2.1.2-brightgreen.svg?maxAge=2592000 )] ( https://github.com/swoole/swoole-src )
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ function __construct(Request $request)
106106 $ this ->success = true ;
107107 break ;
108108 case 3 :
109- if (!$ this ->hasHeader ('Location ' )) {
109+ if (!$ this ->hasHeader ('Location ' ) || $ request -> getRedirect () === 0 ) {
110110 /* not a redirect response */
111111 $ this ->success = true ;
112112 break ;
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ public function testExceptions()
127127 $ this ->expectException (ServerException::class);
128128 $ saber ->get ('http://www.httpbin.org/status/500 ' );
129129 $ this ->expectException (TooManyRedirectsException::class);
130- $ saber ->get ('http://www.httpbin. org// redirect/1 ' , ['redirect ' => 0 ]);
130+ $ saber ->get ('http://httpbingo. org/redirect/3 ' , ['redirect ' => 1 ]);
131131 }
132132
133133 /**
@@ -316,7 +316,7 @@ public function testDownload()
316316 public function testBeforeRedirect ()
317317 {
318318 $ response = SaberGM::get (
319- 'http://www. httpbingo.org/redirect-to?url=https://www.qq.com/ ' ,
319+ 'http://httpbingo.org/redirect-to?url=https://www.qq.com/ ' ,
320320 [
321321 'before_redirect ' => function (Saber \Request $ request ) {
322322 $ this ->assertEquals ('https://www.qq.com/ ' , (string )$ request ->getUri ());
@@ -420,4 +420,11 @@ public function testPostDataAndUploadFile()
420420
421421 $ this ->assertEquals ($ array ['form ' ]['foo ' ], 'bar ' );
422422 }
423+
424+ public function testNonRedirect ()
425+ {
426+ $ saber = Saber::create (['exception_report ' => true ]);
427+ $ res = $ saber ->get ('http://baidu.com ' , ['redirect ' => 0 ]);
428+ $ this ->assertTrue ((string )$ res ->body !== '' );
429+ }
423430}
You can’t perform that action at this time.
0 commit comments