mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Add detail about "buffer" option
This commit is contained in:
parent
d2f9db8241
commit
6f88caf6e4
18
README.md
18
README.md
@ -376,7 +376,24 @@ proxyServer.listen(8015);
|
|||||||
* **proxyTimeout**: timeout (in millis) for outgoing proxy requests
|
* **proxyTimeout**: timeout (in millis) for outgoing proxy requests
|
||||||
* **timeout**: timeout (in millis) for incoming requests
|
* **timeout**: timeout (in millis) for incoming requests
|
||||||
* **selfHandleRequest** true/false, if set to true, none of the webOutgoing passes are called and its your responsibility ro appropriately return the response by listening and acting on the `proxyRes` event
|
* **selfHandleRequest** true/false, if set to true, none of the webOutgoing passes are called and its your responsibility ro appropriately return the response by listening and acting on the `proxyRes` event
|
||||||
|
* **buffer**: stream of data to send as the request body. Maybe you have some middleware that consumes the request stream before proxying it on e.g. If you read the body of a request into a field called 'req.rawbody' you could restream this field in the buffer option:
|
||||||
|
|
||||||
|
```
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const streamify = require('stream-array');
|
||||||
|
const HttpProxy = require('http-proxy');
|
||||||
|
const proxy = new HttpProxy();
|
||||||
|
|
||||||
|
module.exports = (req, res, next) => {
|
||||||
|
|
||||||
|
proxy.web(req, res, {
|
||||||
|
target: 'http://localhost:4003/',
|
||||||
|
buffer: streamify(req.rawBody)
|
||||||
|
}, next);
|
||||||
|
|
||||||
|
};
|
||||||
|
```
|
||||||
**NOTE:**
|
**NOTE:**
|
||||||
`options.ws` and `options.ssl` are optional.
|
`options.ws` and `options.ssl` are optional.
|
||||||
`options.target` and `options.forward` cannot both be missing
|
`options.target` and `options.forward` cannot both be missing
|
||||||
@ -386,6 +403,7 @@ If you are using the `proxyServer.listen` method, the following options are also
|
|||||||
* **ssl**: object to be passed to https.createServer()
|
* **ssl**: object to be passed to https.createServer()
|
||||||
* **ws**: true/false, if you want to proxy websockets
|
* **ws**: true/false, if you want to proxy websockets
|
||||||
|
|
||||||
|
|
||||||
**[Back to top](#table-of-contents)**
|
**[Back to top](#table-of-contents)**
|
||||||
|
|
||||||
### Listening for proxy events
|
### Listening for proxy events
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user