File tree 4 files changed +12
-5
lines changed
4 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1
1
# Saber
2
2
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 )
4
4
[ ![ PHPUnit for Saber] ( https://github.com/swlib/saber/workflows/PHPUnit%20for%20Saber/badge.svg )] ( https://github.com/swlib/saber/actions )
5
5
[ ![ Php Version] ( https://img.shields.io/badge/php-%3E=7.1-brightgreen.svg?maxAge=2592000 )] ( https://secure.php.net/ )
6
6
[ ![ 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 1
1
# Saber
2
2
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 )
4
4
[ ![ PHPUnit for Saber] ( https://github.com/swlib/saber/workflows/PHPUnit%20for%20Saber/badge.svg )] ( https://github.com/swlib/saber/actions )
5
5
[ ![ Php Version] ( https://img.shields.io/badge/php-%3E=7.1-brightgreen.svg?maxAge=2592000 )] ( https://secure.php.net/ )
6
6
[ ![ 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)
106
106
$ this ->success = true ;
107
107
break ;
108
108
case 3 :
109
- if (!$ this ->hasHeader ('Location ' )) {
109
+ if (!$ this ->hasHeader ('Location ' ) || $ request -> getRedirect () === 0 ) {
110
110
/* not a redirect response */
111
111
$ this ->success = true ;
112
112
break ;
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ public function testExceptions()
127
127
$ this ->expectException (ServerException::class);
128
128
$ saber ->get ('http://www.httpbin.org/status/500 ' );
129
129
$ 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 ]);
131
131
}
132
132
133
133
/**
@@ -316,7 +316,7 @@ public function testDownload()
316
316
public function testBeforeRedirect ()
317
317
{
318
318
$ 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/ ' ,
320
320
[
321
321
'before_redirect ' => function (Saber \Request $ request ) {
322
322
$ this ->assertEquals ('https://www.qq.com/ ' , (string )$ request ->getUri ());
@@ -420,4 +420,11 @@ public function testPostDataAndUploadFile()
420
420
421
421
$ this ->assertEquals ($ array ['form ' ]['foo ' ], 'bar ' );
422
422
}
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
+ }
423
430
}
You can’t perform that action at this time.
0 commit comments