HttpFoundation Component
The HttpFoundation component defines an object-oriented layer for the HTTP specification.
The HttpFoundation component defines an object-oriented layer for the HTTP specification.
Using Memcache::set()
in a multi-server environment can yield unexpected results:
http://docs.php.net/manual/en/memcache.replace.php#100023
It's best to attempt replace()
first and only use set()
if the key does not exist.
Q | A -- | -- Branch? | 5.4 Bug fix? | no New feature? | yes Deprecations? | no Tickets | - License | MIT Doc PR | -
This PR allow support for RFC5861.
Meaning you can now use stale_while_revalidate and stale_if_error
https://httpwg.org/specs/rfc5861.html
Very interesting doc from Fastly on the subject:
https://developer.fastly.com/learning/concepts/stale/
Link to the issue https://github.com/symfony/symfony/issues/45036
session_start() runs in the current logic for Native Sessions here without checking first if the session has already started previous to the code running.
Back / forward cache seems to be a fairly recent feature browsers seem to rollout.
More information can be found here: https://web.dev/bfcache.
Long story short, when a user for example login then logout from a given application, they could then hit the "Back" button from their browser and access the login page again with the credentials pre-filled as the page would be served from the bfcache
. This could lead to security concerns, especially on shared devices where someone could inspect the page and retrieve some user credentials.
Currently, the sensible defaults for the HTTP cache headers seem to be no-cache, private
in order to be conservative by default. A lot of applications currently rely on this to be the sensible default for their application too.
Replacing no-cache
by no-store
would prevent bfcache
to kick in from any browser and could be considered as a more secure default.
no-cache
shows that returned responses can't be used for subsequent requests to the same URL before checking if server responses have changed. If a properETag
(validation token) is present as a result,no-cache
incurs a roundtrip in an effort to validate cached responses. Caches can however eliminate downloads if the resources haven't changed. In other words, web browsers might cache the assets but they have to check on every request if the assets have changed (304 response if nothing has changed).
On the contrary,
no-store
is simpler. This is the case because it disallows browsers and all intermediate caches from storing any versions of returned responses, such as responses containing private/personal information or banking data. Every time users request this asset, requests are sent to the server. The assets are downloaded every time.
More information can be found here: https://www.keycdn.com/blog/http-cache-headers#no-cache-and-no-store
The purpose of this PR is to start the discussion rather than bringing a definite solution.
When you want to send headers before request finishes via
class MyController {
public function myAction() {
$response = new Response();
$response->headers->set(
'Content-Disposition',
HeaderUtils::makeDisposition(
HeaderUtils::DISPOSITION_ATTACHMENT,
'file.txt
)
);
$response->sendHeaders();
ob_flush();
flush();
// do some work to populate response
sleep(5); // this is only for demonstraton purposes
return $response;
}
}
I get a warning error
E_WARNING: Cannot modify header information - headers already sent in [Root folder]/vendor/symfony/http-foundation/Session/SessionUtils.php, line 54
With this PR the headers get only manipulated during kernel.response
event if the headers have ot already been sent.
Who suggest the "we should reverse x-forwarded-for ip addresses list" idea and who accepted this i don't know but this behavior is wrong. Client ip address is first one of x-forwarded-for ip address list and if there is a 1 or multiple gateway between client and server, gateway ip addresses are added last of array.
References:
Added 300 code to array of valid redirections in isRedirect().
This remains consistent with deprecated isRedirection() which checked >= 300.
Not supporting 300 has effects on downstream projects drupal/redirect : https://www.drupal.org/node/2920454
If there is a good reason for removing support for 300, perhaps it would be a good time to document that.
Thanks!
In our app we use trusted proxies. Using Blackfire we found IpUtils::checkIp
was being called 454 times taking 3.15ms.
Caching the result saves those 3ms.
When apache does internal redirect with mod_rewrite it stores proper URI in server variable REDIRECT_URL.
Patch to adjust creating $requestUri based on this variable.
Normally you wouldn't call Request::createFromGlobals() more than once, but sometimes it happens due to bad design in legacy code. Instead of processing the same request data on every call, the parsed result should be stored in a static property on the first call and return the cached data on subsequent calls.
Output buffers must be properly flushed so the following example could work as expected. /**
See PHP RFC: Deprecate autovivification on false https://wiki.php.net/rfc/autovivification_false
Got the error on a Drupal instance with memcache module and memcache_admin sub module enabled.
PHP: 8.1.11 Drupal core: 9.5.0-rc1 memcache module : 2.5.0
Note: in the test: memcache:11211 (hostname: memcache, port: 11211) is the memcached instance running with the docker image bitnami/memcached:1.6.9
Location: https://example.com/admin/reports/memcache/default/memcache%3A11211 Referrer: https://example.com/admin/reports/memcache/default Message (partial):
Changelog (https://github.com/symfony/http-foundation/compare/v6.2.1...v6.2.2)
Changelog (https://github.com/symfony/http-foundation/compare/v6.2.0...v6.2.1)
Changelog (https://github.com/symfony/http-foundation/compare/v6.2.0-RC2...v6.2.0)
Changelog (https://github.com/symfony/http-foundation/compare/v6.1.7...v6.1.8)
Changelog (https://github.com/symfony/http-foundation/compare/v6.0.15...v6.0.16)
Changelog (https://github.com/symfony/http-foundation/compare/v5.4.15...v5.4.16)
Changelog (https://github.com/symfony/http-foundation/compare/v4.4.48...v4.4.49)
Changelog (https://github.com/symfony/http-foundation/compare/v6.2.0-BETA3...v6.2.0-RC1)
Changelog (https://github.com/symfony/http-foundation/compare/v6.2.0-BETA2...v6.2.0-BETA3)
Changelog (https://github.com/symfony/http-foundation/compare/v6.1.6...v6.1.7)
Changelog (https://github.com/symfony/http-foundation/compare/v6.0.14...v6.0.15)
Changelog (https://github.com/symfony/http-foundation/compare/v5.4.14...v5.4.15)
Changelog (https://github.com/symfony/http-foundation/compare/v4.4.47...v4.4.48)
Changelog (https://github.com/symfony/http-foundation/compare/v6.1.6...v6.2.0-BETA1)
Changelog (https://github.com/symfony/http-foundation/compare/v6.1.5...v6.1.6)
Changelog (https://github.com/symfony/http-foundation/compare/v6.0.13...v6.0.14)
Changelog (https://github.com/symfony/http-foundation/compare/v5.4.13...v5.4.14)
Changelog (https://github.com/symfony/http-foundation/compare/v4.4.46...v4.4.47)
Changelog (https://github.com/symfony/http-foundation/compare/v6.1.4...v6.1.5)
Changelog (https://github.com/symfony/http-foundation/compare/v6.0.12...v6.0.13)
Changelog (https://github.com/symfony/http-foundation/compare/v5.4.12...v5.4.13)
Changelog (https://github.com/symfony/http-foundation/compare/v4.4.45...v4.4.46)
Changelog (https://github.com/symfony/http-foundation/compare/v6.1.3...v6.1.4)
Changelog (https://github.com/symfony/http-foundation/compare/v6.0.11...v6.0.12)
Changelog (https://github.com/symfony/http-foundation/compare/v5.4.11...v5.4.12)
Changelog (https://github.com/symfony/http-foundation/compare/v4.4.44...v4.4.45)
Changelog (https://github.com/symfony/http-foundation/compare/v6.1.2...v6.1.3)
\Stringable
support in InputBag::get()
(chalasr)$_SESSION
in NativeSessionStorage::save()
(chalasr)Changelog (https://github.com/symfony/http-foundation/compare/v6.0.10...v6.0.11)
\Stringable
support in InputBag::get()
(chalasr)$_SESSION
in NativeSessionStorage::save()
(chalasr)Changelog (https://github.com/symfony/http-foundation/compare/v5.4.10...v5.4.11)
$_SESSION
in NativeSessionStorage::save()
(chalasr)Changelog (https://github.com/symfony/http-foundation/compare/v4.4.43...v4.4.44)
$_SESSION
in NativeSessionStorage::save()
(chalasr)Deprecated, Unmaintained This repo contains the Hack Language Specification, a modified version of the PHP specification. It is no longer maintained a
Waffler How to install? $ composer require waffler/waffler This package requires PHP 8 or above. How to test? $ composer phpunit Quick start For our e
HttpClient component The HttpClient component provides powerful methods to fetch HTTP resources synchronously or asynchronously. Resources Documentati
Guzzle, PHP HTTP client Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services. Simple interf
Requests for PHP Requests is a HTTP library written in PHP, for human beings. It is roughly based on the API from the excellent Requests Python librar
Httpful Httpful is a simple Http Client library for PHP 7.2+. There is an emphasis of readability, simplicity, and flexibility – basically provide the
Buzz - Scripted HTTP browser Buzz is a lightweight (<1000 lines of code) PHP 7.1 library for issuing HTTP requests. The library includes three clients
HTTPlug HTTPlug, the HTTP client abstraction for PHP. Intro HTTP client standard built on PSR-7 HTTP messages. The HTTPlug client interface is compati
zend-diactoros Repository abandoned 2019-12-31 This repository has moved to laminas/laminas-diactoros. Master: Develop: Diactoros (pronunciation: /dɪʌ
This is a port of the VCR Ruby library to PHP. Record your test suite's HTTP interactions and replay them during future test runs for fast, determinis
Requests for PHP Requests is a HTTP library written in PHP, for human beings. It is roughly based on the API from the excellent Requests Python librar
laminas-diactoros Diactoros (pronunciation: /dɪʌktɒrɒs/): an epithet for Hermes, meaning literally, "the messenger." This package supercedes and repla
Unirest for PHP Unirest is a set of lightweight HTTP libraries available in multiple languages, built and maintained by Mashape, who also maintain the
PHP Curl Class: HTTP requests made easy PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs. Installation Requirements Quic
HTTP header kit for PHP 7.1+ (incl. PHP 8) based on PSR-7 Installation composer require sunrise/http-header-kit How to use? HTTP Header Collection Mor
Bypass for PHP provides a quick way to create a custom HTTP Server to return predefined responses to client requests.Useful for tests with Pest PHP or PHPUnit.
Request Logger Made by Adam Langley ( https://twitter.com/adamtlangley ) What is it? Request logger is a free and open source utility for logging HTTP
tus is a HTTP based protocol for resumable file uploads. Resumable means you can carry on where you left off without re-uploading whole data again in case of any interruptions. An interruption may happen willingly if the user wants to pause, or by accident in case of a network issue or server outage.
librestful is a virion for PocketMine servers that make easier, readable code for async rest requests.