Skip to content

Commit

Permalink
Clarify server request and server response in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Apr 4, 2020
1 parent 74d66b2 commit b11f2d7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions documentation/migration-guides.md
Expand Up @@ -141,9 +141,9 @@ Hooks are powerful, aren't they? [Read more](../readme.md#hooks) to see what els
Let's take a quick look at another example from Request's readme:

```js
http.createServer((request, response) => {
if (request.url === '/doodle.png') {
request.pipe(request('https://example.com/doodle.png')).pipe(response);
http.createServer((serverRequest, serverResponse) => {
if (serverRequest.url === '/doodle.png') {
serverRequest.pipe(request('https://example.com/doodle.png')).pipe(serverResponse);
}
});
```
Expand All @@ -157,15 +157,15 @@ const got = require('got');

const pipeline = promisify(stream.pipeline);

http.createServer(async (request, response) => {
if (request.url === '/doodle.png') {
http.createServer(async (serverRequest, serverResponse) => {
if (serverRequest.url === '/doodle.png') {
// When someone makes a request to our server, we receive a body and some headers.
// These are passed to Got. Got proxies downloaded data to our server response,
// so you don't have to do `response.writeHead(statusCode, headers)` and `response.end(body)`.
// It's done automatically.
await pipeline(
got.stream('https://example.com/doodle.png'),
response
serverResponse
);
}
});
Expand Down

0 comments on commit b11f2d7

Please sign in to comment.