38 Commits

Author SHA1 Message Date
François Leurent
220f5fb795 Expose full callback names 2016-10-22 11:45:16 -04:00
François Leurent
d48f67eb90 Do not rely on func.name (no scope) 2016-10-22 11:45:16 -04:00
Alex Indigo
b781af641a Made it not to crash with omited Host http header (#1050) 2016-09-14 07:03:48 -04:00
Deividy Metheler
42df703830 Emit disconnected event instead of error when ECONNRESET (#966)
* Emit disconnected event instead of error when ECONNRESET

ECONNRESET means the other side of the TCP conversation abruptly
closed its end of the connection.

If we get an ECONNRESET error from the proxy request and the
socket is destroyed this means that the client has closed
his connection, and emit this as an error can lead to
confusion and hacks to filter that kind of message.

I think that the best we can do is abort and emit another event,
so if any caller wants to handle with that kind of error, he can
by listen the disconnected event.

https://github.com/nodejitsu/node-http-proxy/issues/813

* code standards, move econnreset check, change ev name
2016-06-03 13:39:40 -04:00
Jakob Backlund
ef86b50427 Set the x-forwarded-host flag when xfwd is enabled
Reasoning: Rack's request class [makes use of](https://github.com/rack/rack/blob/master/lib/rack/request.rb#L243) this HTTP header. Certain edge-case scenarios (proxying from ember-cli to a Rails backend) can be problematic without this header being present.

/cc @perlun, @jesjos
2016-02-26 14:29:55 +02:00
Tobias Bieniek
5c46e4b754 Remove "transfer-encoding" header if "content-length" is set to zero 2016-02-15 15:43:14 +01:00
Jeremy Judeaux
5f14bcaa70 fix protocol and default port detection on node 0.12.x, compatible with 0.10.x 2015-04-02 14:23:58 +02:00
Feross Aboukhadijeh
6d074eff47 fix "x-forwarded-proto" in node 0.12 and iojs
The way to detect TLSSockets in node 0.12 and iojs has changed. You can
just check `socket.encrypted` now :)

Fixes #772
2015-03-11 00:33:34 -07:00
Jarrett Cruger
ea0a4ded80 [fix] style spacing wtf 2014-12-17 00:53:51 -07:00
Jarrett Cruger
95a588706b Merge pull request #741 from samccone/sjs/redirect-host-rewrite
Allow optional redirect host rewriting.
2014-11-25 17:08:54 -05:00
Mike Pennisi
8a24a1e18f Set Content-Length header for OPTIONS requests
Web browsers automatically issue an OPTIONS request in advance of other
HTTP requests when the document's domain does not match the target in
order to facilitate Cross-Origin Resource Sharing. These requests are
forbidden from specifying a body and typically do not specify an
(unecessary) `Length` header.

Node.js automatically adds the `Content-Encoding: chunked` header value
to requests that do not specify a `Length` header. This makes proxied
OPTIONS requests from web browsers invalid.

Explicitly set the `Content-Length` header of all `OPTIONS` requests to
"0", disabling the default "chunked" encoding behavior [2].

[1] http://www.w3.org/TR/cors/
[2] http://nodejs.org/api/http.html
2014-11-24 17:14:48 -05:00
Sam Saccone
daf66a7a88 Allow optional redirect host rewriting. 2014-11-23 19:22:07 -05:00
jleal52
9ba8311343 Updated to support error callback on proxy.web and start/proxyReq/end continue working. 2014-11-12 14:41:46 +00:00
Manu Sporny
db5f2954b2 [api] Add event-based ability to modify pre-flight proxy requests. 2014-07-18 11:46:04 -04:00
Jarrett Cruger
d1baa3684e [api] also emit the target on a proxy error 2014-07-08 16:12:57 -04:00
Damian Kaczmarek
7b79a7409a Change name targetTimeout to proxyTimeout 2014-06-10 19:04:12 +02:00
Damian Kaczmarek
0f243516e1 Added targetTimeout option and two tests for timeout 2014-06-10 01:35:53 +02:00
Bryce Gibson
1213e46b1b Add the req and res objects to the proxyRes event 2014-05-12 08:22:54 +10:00
Jarrett Cruger
77a1cff9bc [fix] handle error on incoming request as well and properly abort proxy if client request is aborted 2014-04-14 13:08:10 -04:00
Jarrett Cruger
4f07dc220d [fix] let user make the decision on what to do with the buffer 2014-04-10 20:02:46 -04:00
Jarrett Cruger
8b48a9fdab [api] emit a start an an end event 2014-04-09 13:38:13 -04:00
yawnt
e936d186b6 [fix] closes #555 2014-01-19 11:49:26 +01:00
Mike Moulton
969a623542 Only emit response if a valid server is present 2014-01-14 00:45:42 -07:00
yawnt
97e4600e94 [fix] fixes #341 2013-12-18 12:33:23 +01:00
yawnt
961d2f9400 [fix] support target and forward 2013-11-08 20:56:26 +01:00
yawnt
590bb604da [fix] _ because it is unused 2013-11-07 19:00:01 +01:00
yawnt
dda6f7a45a [feature] add emit proxyRes 2013-11-05 17:44:04 +01:00
yawnt
1204a35e46 [fix] support buffer 2013-10-29 18:12:23 +01:00
yawnt
e3f8d5fdbe [feature] add buffer support 2013-10-26 17:20:30 +02:00
cronopio
cc09ae6a34 [fix] use the correct arguments order 2013-10-21 21:19:52 -05:00
mmoulton
0bfb9be418 Fixed issue where error callback would not invoke, including new test cases. Added req/res values to error events.
Conflicts:
	lib/http-proxy/passes/web-incoming.js
2013-10-21 17:36:20 -05:00
cronopio
babdf531fe Revert "[fix] fixed options and server reference to can access them from passes functions"
This reverts commit 90fb01d38ac5af7ef395547b24e985b6f63b4abc.
2013-10-21 14:45:03 -05:00
cronopio
2bf20d61d5 Revert "[tests] fix test to use the new way to pass options"
This reverts commit 52ecd52ee5aa78603e44ba8d5ff9187410351622.
2013-10-21 14:44:49 -05:00
cronopio
52ecd52ee5 [tests] fix test to use the new way to pass options 2013-10-21 03:59:14 -05:00
cronopio
90fb01d38a [fix] fixed options and server reference to can access them from passes functions 2013-10-21 03:26:54 -05:00
yawnt
c7924e01f9 [fix] callback as optional error handler 2013-10-09 17:23:44 +02:00
yawnt
601dbcbfe9 [fix] refactor error handling 2013-10-09 16:59:03 +02:00
indexzero
bb0d28c587 [refactor minor] s/caronte/http-proxy/ or s/caronte/httpProxy/ where appropriate. 2013-09-26 03:37:08 -04:00