Skip to content

Commit

Permalink
Disable redirect handling in the adapter.
Browse files Browse the repository at this point in the history
Redirect handling has been moved into the client because of cookie
handling issues. See #10876
  • Loading branch information
markstory committed Jul 9, 2017
1 parent 1d3c573 commit e0910ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Http/Client/Adapter/Stream.php
Expand Up @@ -198,9 +198,9 @@ protected function _buildOptions(Request $request, $options)
if (isset($options['timeout'])) {
$this->_contextOptions['timeout'] = $options['timeout'];
}
if (isset($options['redirect'])) {
$this->_contextOptions['max_redirects'] = (int)$options['redirect'];
}
// Redirects are handled in the client layer because of cookie handling issues.
$this->_contextOptions['max_redirects'] = 0;

if (isset($options['proxy']['proxy'])) {
$this->_contextOptions['request_fulluri'] = true;
$this->_contextOptions['proxy'] = $options['proxy']['proxy'];
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Http/Client/Adapter/StreamTest.php
Expand Up @@ -182,7 +182,7 @@ public function testBuildingContextHeader()
'Cookie: testing=value; utm_src=awesome',
];
$this->assertEquals(implode("\r\n", $expected), $result['header']);
$this->assertEquals($options['redirect'], $result['max_redirects']);
$this->assertSame(0, $result['max_redirects']);
$this->assertTrue($result['ignore_errors']);
}

Expand Down

6 comments on commit e0910ea

@robertpustulka
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markstory I left that untouched intentionally in order to keep BC. But maybe that's not an issue, as this class is used rather internally.

@markstory
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you leave it in, the cookie issue won't be fixed as the PHP stream layer will still follow redirects.

@robertpustulka
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's why I unset the option:

unset($options['redirect']);

@markstory
Copy link
Member Author

@markstory markstory commented on e0910ea Jul 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So then its double disabled now 😄

@robertpustulka
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markstory I'm just wondering if this change won't break someone's code.

@markstory
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt it. If it does, we'll have to deal with that.

Please sign in to comment.