Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] http 304 响应会导致错误的重定向处理 #3

Closed
NHZEX opened this issue Apr 11, 2020 · 1 comment
Closed

[BUG] http 304 响应会导致错误的重定向处理 #3

NHZEX opened this issue Apr 11, 2020 · 1 comment
Labels

Comments

@NHZEX
Copy link
Contributor

NHZEX commented Apr 11, 2020

[Argument 1 passed to Yurun\Util\YurunHttp\Http\Psr7\Request::withUri() must implement interface Psr\Http\Message\UriInterface, null given, called in /home/vagrant/code/project/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole.php on line 307
#class: TypeError
#0 /home/vagrant/code/project/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole.php(307): Yurun\Util\YurunHttp\Http\Psr7\Request->withUri(NULL)
#1 /home/vagrant/code/project/vendor/yurunsoft/yurun-http/src/YurunHttp/Handler/Swoole.php(189): Yurun\Util\YurunHttp\Handler\Swoole->recvDefer(Object(Yurun\Util\YurunHttp\Http\Request))
#2 /home/vagrant/code/project/vendor/yurunsoft/yurun-http/src/YurunHttp.php(97): Yurun\Util\YurunHttp\Handler\Swoole->send(Object(Yurun\Util\YurunHttp\Http\Request))
#3 /home/vagrant/code/project/vendor/yurunsoft/yurun-http/src/HttpRequest.php(756): Yurun\Util\YurunHttp::send(Object(Yurun\Util\YurunHttp\Http\Request), Object(Yurun\Util\YurunHttp\Handler\Swoole))
#4 /home/vagrant/code/project/vendor/yurunsoft/yurun-http/src/HttpRequest.php(795): Yurun\Util\HttpRequest->send('http://devimage...', Array, 'GET')
#5 /home/vagrant/code/project/App/HttpController/Auth.php(231): Yurun\Util\HttpRequest->get('http://devimage...')
#6 /home/vagrant/code/project/App/HttpController/Auth.php(182): App\HttpController\Auth->handleM3u8('iphone/samples/...', Array)
#7 /home/vagrant/code/project/vendor/easyswoole/http/src/AbstractInterface/Controller.php(115): App\HttpController\Auth->index()
#8 /home/vagrant/code/project/vendor/easyswoole/http/src/Dispatcher.php(182): EasySwoole\Http\AbstractInterface\Controller->__hook('index', Object(EasySwoole\Http\Request), Object(EasySwoole\Http\Response))
#9 /home/vagrant/code/project/vendor/easyswoole/http/src/Dispatcher.php(137): EasySwoole\Http\Dispatcher->controllerHandler(Object(EasySwoole\Http\Request), Object(EasySwoole\Http\Response), '/Auth')
#10 /home/vagrant/code/project/vendor/easyswoole/easyswoole/src/Core.php(255): EasySwoole\Http\Dispatcher->dispatch(Object(EasySwoole\Http\Request), Object(EasySwoole\Http\Response))

if(!$isWebSocket && $statusCode >= 300 && $statusCode < 400 && $request->getAttribute(Attributes::FOLLOW_LOCATION, true))
{
if(++$redirectCount <= ($maxRedirects = $request->getAttribute(Attributes::MAX_REDIRECTS, 10)))
{
// 自己实现重定向
$uri = $this->parseRedirectLocation($this->result->getHeaderLine('location'), $request->getUri());
if(in_array($statusCode, [301, 302, 303]))
{
$method = 'GET';
}
else
{
$method = $request->getMethod();
}
return $this->send($request->withMethod($method)->withUri($uri)->withAttribute(Attributes::PRIVATE_REDIRECT_COUNT, $redirectCount));
}
else
{
$this->result = $this->result->withErrno(-1)
->withError(sprintf('Maximum (%s) redirects followed', $maxRedirects));
return false;
}
}

http code 的定义:
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Status

location 只有 301、302、303、307、308 才会存在
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Location

@Yurunsoft
Copy link
Owner

已在 5076c84 中修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants