Skip to content
Permalink
Browse files

Disable redirect handling in the adapter.

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 e0910ea3a4db1176898412a48bbecff9c0ad9d93
Showing with 4 additions and 4 deletions.
  1. +3 −3 src/Http/Client/Adapter/Stream.php
  2. +1 −1 tests/TestCase/Http/Client/Adapter/StreamTest.php
@@ -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'];
@@ -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']);
}

6 comments on commit e0910ea

@robertpustulka

This comment has been minimized.

Copy link
Member

robertpustulka replied Jul 10, 2017

@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

This comment has been minimized.

Copy link
Member Author

markstory replied Jul 10, 2017

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

@robertpustulka

This comment has been minimized.

Copy link
Member

robertpustulka replied Jul 10, 2017

Yes, that's why I unset the option:

unset($options['redirect']);

@markstory

This comment has been minimized.

Copy link
Member Author

markstory replied Jul 10, 2017

So then its double disabled now 😄

@robertpustulka

This comment has been minimized.

Copy link
Member

robertpustulka replied Jul 10, 2017

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

@markstory

This comment has been minimized.

Copy link
Member Author

markstory replied Jul 10, 2017

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

Please sign in to comment.
You can’t perform that action at this time.