Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpClient] Unable to set$info['redirect_url'] via MockResponse #59324

Open
@defunctl

Description

@defunctl

Symfony version(s) affected

5.x+

Description

Setting'redirect_url' => 'http://www.mysite.test/final/' as part of the$info array in a MockResponse results in:

Symfony\Component\HttpClient\Exception\TransportException] The response factory iterator passed to MockHttpClient is empty.
$responses = [newMockResponse('',['http_code'        =>301,'redirect_url'     =>'http://www.mysite.test/final/','response_headers' => ['HTTP/2 301','location: http://www.mysite.test/final/',],]),];

It seems to be forceinfo['redirect_url'] to nullhere.

How to reproduce

I am using a decorator in my code, but this PHPUnit test should fail regardless:

$responses = [newMockResponse('',['http_code'        =>301,'redirect_url'     =>'http://www.mysite.test/final/','response_headers' => ['HTTP/2 301','location: http://www.mysite.test/final/',],]),];$this->http_client->setResponseFactory($responses );try {$response =$this->client->request('GET','/redirect/' );$response->getHeaders();$this->fail('A RedirectionException should have been thrown' );}catch (RedirectionExceptionInterface$e ) {$info =$e->getResponse()->getInfo();$this->assertSame('http://www.mysite.test/final/',$info['redirect_url'] );}

Possible Solution

Either allow us to set$info['redirect_url'] on MockResponse, or it should populate it automatically based on the response_headers?

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp