Skip to content

http.follow_location default #5832

Description

@Sjord

Affected page

https://www.php.net/manual/en/context.http.php

Issue description

follow_location int
Follow Location header redirects. Set to 0 to disable.

Defaults to 1.

Steps to reproduce

If http.follow_location is set, it determines whether redirects are followed never or always. When it is not set, redirects are followed on status code 300, 301, 302, 303, 307 and 308.

Not setting it is different then setting it to 1. So it is incorrect to say that the default value is 1.

ext/standard/http_fopen_wrapper.c

/* Check if the location should be followed. */
if (context && (tmpzval = php_stream_context_get_option(context, "http", "follow_location")) != NULL) {
	header_info->follow_location = zend_is_true(tmpzval);
} else if (!((response_code >= 300 && response_code < 304)
		|| 307 == response_code || 308 == response_code)) {
	/* The redirection should not be automatic if follow_location is not set and
		* response_code not in (300, 301, 302, 303 and 307)
		* see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1
		* RFC 7238 defines 308: http://tools.ietf.org/html/rfc7238 */
	header_info->follow_location = false;
}

Suggested fix

No response

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDocumentation contains incorrect information

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions