Skip to content

[TASK] Do not follow redirects in API requests - #36

Open
sfsmfc wants to merge 1 commit into
developfrom
task/disable-api-redirects
Open

sfsmfc wants to merge 1 commit into
developfrom
task/disable-api-redirects

Conversation

@sfsmfc

@sfsmfc sfsmfc commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

The API does not use redirects. The API client followed them all the same.

Disable redirects for all API requests, so each request goes only to the configured API host. Set a timeout of 10 seconds.


The API does not use redirects. The API client followed them all the
same.

Disable redirects for all API requests, so each request goes only to
the configured API host. Set a timeout of 10 seconds.

#[Test]
public function getRequestOptionsReturnsTrueByDefault(): void
public function getRequestOptionsVerifiesSslByDefault(): void

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If the test is about verify SSL, don't compare the full array, but only the verify key. Otherwise each update of request options would require updating this test, although nothing changed regarding its purpose.

public function getRequestOptionsDisablesSslVerificationWhenConfigured(): void
{
self::assertSame(['verify' => false], $this->buildSubject(verifySsl: '0')->getRequestOptions());
self::assertSame(['verify' => false, 'allow_redirects' => false, 'timeout' => 10], $this->buildSubject(verifySsl: '0')->getRequestOptions());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If the test is about verify SSL, don't compare the full array, but only the verify key. Otherwise each update of request options would require updating this test, although nothing changed regarding its purpose.

}

// The response for the redirect target stays in the queue: the client sends only one request.
self::assertCount(1, $this->mockHandler);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd prefer checking the client's final URL over relying on a non-empty stack. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants