Skip to content

Commit ab28eef

Browse files
authored
Added a section about contribution and fixed typos (#377)
1 parent 66c7776 commit ab28eef

File tree

7 files changed

+29
-21
lines changed

7 files changed

+29
-21
lines changed

Diff for: CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ All exceptions will be handled in the callback.
6262
- Added `ParameterBag` to store options.
6363
- Added `BatchClientInterface::sendAsyncRequest(RequestInterface $request, array $options = [])`.
6464
- Added `BuzzClientInterface::sendRequest(RequestInterface $request, array $options = []): ResponseInterface`.
65-
- Ported all Listeners to Middlewares.
65+
- Ported all Listeners to Middleware.
6666
- Added options to configure the client as constructor argument and when you send a request.
6767

6868
### Removed (BC breaks)
@@ -123,7 +123,7 @@ All exceptions will be handled in the callback.
123123
* Added Request and Response converters
124124
* Added `Curl::sendRequest()`, `MultiCurl::sendRequest()` and `FileGetContents::sendRequest()` that
125125
supports sending PSR-7 requests.
126-
* Added `Browser::sendRequest()` that supports middlewares.
126+
* Added `Browser::sendRequest()` that supports middleware.
127127
* Added `MiddlewareInterface` and `Browser::addMiddleware()`.
128128
* Added `HeaderConverter` to convert between PSR-7 styled headers and Buzz styled headers.
129129

Diff for: README.md

+8
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ compatibility.
132132
Being greatly inspired by [Symfony's bc promise](https://symfony.com/doc/current/contributing/code/bc.html), we have adopted
133133
their method of deprecating classes, interfaces and functions.
134134

135+
## Contribute
136+
137+
Buzz is great because it is small, simple and yet flexible. We are always happy to receive bug reports and bug fixes. We
138+
are also looking forward to review a pull request with a new middleware, especially if the middleware covers a common
139+
use case.
140+
141+
We will probably not accept any configuration option or feature to any of the clients or the Browser.
142+
135143
## Running the tests
136144

137145
There are 2 kinds of tests for this library; unit tests and integration tests. They can be run separably by:

Diff for: doc/index.md renamed to doc/Readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ reading.
77
* [Browser](#browser)
88
* [Submit forms](#submit-a-form)
99
* [Client](/doc/client.md)
10-
* [Middlewares](/doc/middlewares.md)
10+
* [Middleware](/doc/middleware.md)
1111
* [Symfony Bundle](/doc/symfony.md)
1212

1313

Diff for: doc/client.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[<-- Index](/doc/index.md)
1+
[<-- Index](/doc/Readme.md)
22

33
# Clients
44

@@ -94,10 +94,10 @@ A proxy server to use when sending requests.
9494
#### push_function_callback
9595

9696
Type: callable, null<br>
97-
Default: `null`
97+
Default: `null`<br>
9898
*Only for MultiCurl*
9999

100-
A callable for `CURLMOPT_PUSHFUNCTION`. See [PHP docs](http://php.net/manual/en/function.curl-multi-setopt.php)
100+
A callable for `CURLMOPT_PUSHFUNCTION`. See [PHP docs](http://php.net/manual/en/function.curl-multi-setopt.php).
101101

102102
Since MultiCurl supports adding multiple requests, all Push Functions callbacks are
103103
chained together. If one of them returns `CURL_PUSH_DENY`, then the request will be denied.
@@ -124,7 +124,7 @@ The time to wait before interrupt the request.
124124
#### use_pushed_response
125125

126126
Type: boolean<br>
127-
Default: `true`
127+
Default: `true`<br>
128128
*Only for MultiCurl*
129129

130130
If true, we can used responses pushed to us by HTTP/2.0 server push.
@@ -138,4 +138,4 @@ If SSL protocols should verified.
138138

139139
---
140140

141-
Continue reading about [Middlewares](/doc/middlewares.md).
141+
Continue reading about [Middleware](/doc/middleware.md).

Diff for: doc/middlewares.md renamed to doc/middleware.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
[<-- Index](/doc/index.md)
1+
[<-- Index](/doc/Readme.md)
22

3-
# Buzz middlewares
3+
# Buzz middleware
44

55
If you want to modify the request or response somehow, a middleware is the way to
66
go. Every time you send a request with the `Browser` it will run through all the
7-
middlewares. The order of the middlewares is important. The first middleware added
7+
middleware. The order of the middleware is important. The first middleware added
88
to the `Browser` will be the first one that is executed when handling the request and
99
the last one to be executed when handling the response.
1010

Diff for: doc/symfony.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[<-- Index](/doc/index.md)
1+
[<-- Index](/doc/Readme.md)
22

33
# Symfony integration
44

@@ -44,4 +44,4 @@ plugins method clients and whatever you want according to the
4444

4545
---
4646

47-
Go back to [index](/doc/index.md).
47+
Go back to [index](/doc/Readme.md).

Diff for: lib/Browser.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Browser implements BuzzClientInterface
2525
/**
2626
* @var MiddlewareInterface[]
2727
*/
28-
private $middlewares = [];
28+
private $middleware = [];
2929

3030
/** @var RequestInterface */
3131
private $lastRequest;
@@ -143,7 +143,7 @@ public function submitForm(string $url, array $fields, string $method = 'POST',
143143
*/
144144
public function sendRequest(RequestInterface $request, array $options = []): ResponseInterface
145145
{
146-
$chain = $this->createMiddlewareChain($this->middlewares, function (RequestInterface $request, callable $responseChain) use ($options) {
146+
$chain = $this->createMiddlewareChain($this->middleware, function (RequestInterface $request, callable $responseChain) use ($options) {
147147
$response = $this->client->sendRequest($request, $options);
148148
$responseChain($request, $response);
149149
}, function (RequestInterface $request, ResponseInterface $response) {
@@ -158,15 +158,15 @@ public function sendRequest(RequestInterface $request, array $options = []): Res
158158
}
159159

160160
/**
161-
* @param MiddlewareInterface[] $middlewares
161+
* @param MiddlewareInterface[] $middleware
162162
*/
163-
private function createMiddlewareChain(array $middlewares, callable $requestChainLast, callable $responseChainLast): callable
163+
private function createMiddlewareChain(array $middleware, callable $requestChainLast, callable $responseChainLast): callable
164164
{
165165
$responseChainNext = $responseChainLast;
166166

167167
// Build response chain
168168
/** @var MiddlewareInterface $middleware */
169-
foreach ($middlewares as $middleware) {
169+
foreach ($middleware as $middleware) {
170170
$lastCallable = function (RequestInterface $request, ResponseInterface $response) use ($middleware, $responseChainNext) {
171171
return $middleware->handleResponse($request, $response, $responseChainNext);
172172
};
@@ -179,12 +179,12 @@ private function createMiddlewareChain(array $middlewares, callable $requestChai
179179
$requestChainLast($request, $responseChainNext);
180180
};
181181

182-
$middlewares = array_reverse($middlewares);
182+
$middleware = array_reverse($middleware);
183183

184184
// Build request chain
185185
$requestChainNext = $requestChainLast;
186186
/** @var MiddlewareInterface $middleware */
187-
foreach ($middlewares as $middleware) {
187+
foreach ($middleware as $middleware) {
188188
$lastCallable = function (RequestInterface $request) use ($middleware, $requestChainNext) {
189189
return $middleware->handleRequest($request, $requestChainNext);
190190
};
@@ -215,7 +215,7 @@ public function getClient(): BuzzClientInterface
215215
*/
216216
public function addMiddleware(MiddlewareInterface $middleware): void
217217
{
218-
$this->middlewares[] = $middleware;
218+
$this->middleware[] = $middleware;
219219
}
220220

221221
private function prepareMultipart(string $name, string $content, string $boundary, array $data = []): string

0 commit comments

Comments
 (0)