Java scripting:
Learn you Node:
This is a Proxy Server for Node.js submitted as the pre-work requirement for CodePath.
Time spent: [4]
Completed:
- Required: Requests to port
8000are echoed back with the same HTTP headers and body - Required: Requests/reponses are proxied to/from the destination server
- Required: The destination server is configurable via the
--host,--portor--urlarguments - Required: The destination server is configurable via the
x-destination-urlheader - Required: Client requests and respones are printed to stdout
- Required: The
--logfileargument outputs all logs to the file specified instead of stdout
npm startcurl -v -X POST http://127.0.0.1:8000 -d "hello self" -H "x-asdf: yodawg"
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> POST /asdf HTTP/1.1
> Host: 127.0.0.1:8000
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 11
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 11 out of 11 bytes
< HTTP/1.1 200 OK
< host: 127.0.0.1:8000
< user-agent: curl/7.43.0
< accept: */*
< content-length: 11
< content-type: application/x-www-form-urlencoded
< Date: Sat, 12 Mar 2016 00:22:10 GMT
< Connection: keep-alive
<
* Connection #0 to host 127.0.0.1 left intact
hello selfPort 8001 will proxy to the echo server on port 8000.
ssahu6:/Users/ssahu6/log$curl -v http://127.0.0.1:8001/asdf -d "hello proxy"
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> POST /asdf HTTP/1.1
> Host: 127.0.0.1:8001
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 11
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 11 out of 11 bytes
< HTTP/1.1 200 OK
< host: 127.0.0.1:8000
< user-agent: curl/7.43.0
< accept: */*
< content-length: 11
< content-type: application/x-www-form-urlencoded
< Date: Sat, 12 Mar 2016 00:22:10 GMT
< Connection: keep-alive
<
* Connection #0 to host 127.0.0.1 left intact
hello proxy
The following CLI arguments are supported:
The host of the destination server. Defaults to 127.0.0.1.
The port of the destination server. Defaults to 80 or 8000 when a host is not specified.
A single url that overrides the above. E.g., http://www.google.com
Specify a file path to redirect logging to.
The follow http header(s) are supported:
Specify the destination url on a per request basis. Overrides and follows the same format as the --url argument.


