Skip to content

Commit 2bcbb43

Browse files
committed
Update README.md
1 parent 900672f commit 2bcbb43

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

CHANGELOG.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,23 @@ Intended to follow [«Keep a Changelog»](https://keepachangelog.com/en/)
88
## [Unreleased] (meant as staging area)
99

1010
### Added
11+
- Two new CookieTranscriptors
12+
- `CookieHeaderTranscriptor`; squeezing `Set-Cookie` headers from PSR-7 into the cookie management of `sfWebRequest`
13+
- `AbstractCookieDispatchTranscriptor`; more powerful, extensible, yet more dangerous approach – using black magic.
14+
- Comes with new `CookieDispatcher`, `DispatchSubstitutor` and a bunch of other cookie related classes
15+
### Changed
16+
- General maintainance: annotations, spelling
17+
- Improving test coverage calculation
18+
- using `@covers` & `@uses` annotations
19+
- enforce using new phpunit settings
20+
- Improve test coverage
21+
- Improve DX (docker, Makefile, gitattributes, cs-fixer rules)
22+
- Extend mocks, due to new functionality
23+
### Deprecated
1124
-
1225

13-
### TODO
14-
- Alter README for new Cookie Transcriptors
26+
27+
## TODO
1528
- Clone the CookieDispatcher-Approach for the ResponseAdapter
1629
- but instead of reading CookieContainer from options → in-situ intercept them → onStatusSent
1730
- Cookies: Write to response
@@ -55,9 +68,9 @@ Intended to follow [«Keep a Changelog»](https://keepachangelog.com/en/)
5568
- Updated dev dependencies
5669
- Update code style
5770

58-
### Fixed
71+
### Security
5972

60-
- downstream vulnerabilities by bumping `guzzlehttp/psr7`
73+
- fixed downstream vulnerabilities by bumping `guzzlehttp/psr7`
6174

6275
## [1.4.0] - 2021-10-19
6376

README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ $response = $entryPoint->handler($response);
8888

8989
Assume you couldn't use other means, and you're confronted with an arbitrary PSR-7 response you can use the `ResponseTranscriptor` to copy the data from your PSR-7 response to your `\sfWebResponse`.
9090

91-
Currently, the `ResponseTranscriptor` doesn't support cookies, and will fail fast and hard if it encounters some. You are free to implement your own Cookie-Handler implementing `CookieTranscriptorInterface` and pass it as an optional constructor argument
91+
The `ResponseTranscriptor` by default uses `NoCookieTranscriptor`, which fails hard in the presence of `Set-Cookie'` headers.
92+
Incorporating (present-day) Cookies into the `\sfWebResponse` is not strait-forward. However, you are free to implement your own Cookie-Handler implementing `CookieTranscriptorInterface` and pass it as an optional constructor argument.
9293

9394
```php
9495
// Given arbitrary PSR-7 response…
@@ -100,6 +101,22 @@ $transcriptor = new \brnc\Symfony1\Message\Transcriptor\ResponseTranscriptor();
100101
$sfWebResponse = $transcriptor->transcribe($psr7response, $sfWebResponse);
101102
```
102103

104+
### Implemented `CookieTranscriptorInterface`s
105+
106+
There are a few CookieTranscriptors already implemented; each come with their specific compromises.
107+
108+
#### `CookieHeaderTranscriptor`
109+
Transcribes `Set-Cookie` headers from your PSR-7 response, into the cookie management of the Symfony1 response.
110+
This comes with all downsides of the legacy signature of `setrawcookie()`. Foremost it's not supporting `SameSite`-attribute, nor everything else being `extension-av` as of RFC 265.
111+
112+
#### `AbstractCookieDispatchTranscriptor`
113+
The (abstract) CookieDispatchTranscriptor uses reflection and swaps the response's EventDispatcher against a new one.
114+
It is very tied against the original implementation of `sfWebResponse::sendHttpHeaders` especially its logging mechanism via events.
115+
The `CookieDispatcher` puts itself between `sfWebResponse` and the original `sfEventDispatcher`, and fires the cookies from the PSR-7 response right before Symfony1 would have sent theirs.
116+
You need to implement `AbstractCookieDispatchTranscriptor`'s `transcribeCookies()` method, depending on your source for the cookies being set. E.g. if your using a 3rd party library.
117+
Your code eventually needs to return `CookieContainerInterface` full of `CookieInterface`s. There is already a `HeaderCookie`, that uses `header()` and expects an already crafted and complete `Set-Cookie`-headerline.
118+
There are also `SetCookie` and `SetRawCookie` which will use the respective methods with the new signature – i.e. three arguments, with the options-array as a third one.
119+
103120
## Pass it down to http-foundation i.e. present-day Symfony
104121

105122
Combine this PSR7-Symfony1 Adapter and `symfony/psr-http-message-bridge` to connect your Symfony1 stack via PSR-7 to `symfony/http-foundation` objects and leverage using embedded (present-day) Symfony components.

0 commit comments

Comments
 (0)