HTTP_PROXY

Hi,

I’m a bit confused as to how the HTTP_PROXY in system settings is picked up. I’ve set it to http://127.0.0.1:8888 to see requests and responses in Fiddler. 

I can see the following two requests are sent to the proxy: 

.Q.hg`:https://www.example.com/ 

.Q.hp[`:https://www.example.com/;“Custom-Type”]“”

How can I ensure that a request like this is picked up by the proxy, as I’d like to see websocket requests in Fiddler?

r:(`$“:ws://echo.websocket.org:80”)“GET / HTTP/1.1\r\nHost: echo.websocket.org:80\r\n\r\n”;

Thanks in advance for any help. 

Hi Student,

.Q.hg and .Q.hp both use the underlying .Q.hmb function which has the proxy support in them (written in q). Essentially they check two env variables; HTTP_PROXY and NO_PROXY; if HTTP_PROXY is set & the URL being requested is not in NO_PROXY, they will use the proxy, which effectively means doing something like

`:https://127.0.0.1:8888 “GET https://www.example.com HTTP/1.1\r\nHost:example.com\r\n\r\n”

as opposed to 

`:https://www.example.com “GET / HTTP/1.1\r\nHost:example.com\r\n\r\n”

You would need to try the following to ensure it is picked up by the proxy:

r:`:ws://127.0.0.1:8888 “GET ws://echo.websocket.org:80 HTTP/1.1\r\nHost:echo.websocket.org\r\n\r\n”

This method of seeing the websocket request is quite manual. If you would like to do this automatically, by reading from HTTP_PROXY if it is set, I would highly recommend using the following websockets library that a colleague of mine wrote: https://github.com/jonathonmcmurray/ws.q

Once cloning this repo, you can access this by entering the following:

~/ws.q$ q ws.q -verbose

q).echo.upd:show;.echo.h:.ws.open[“ws://echo.websocket.org”;`.echo.upd]

– REQUEST –

:ws://echo.websocket.org GET / HTTP/1.1

Host: echo.websocket.org

Origin: echo.websocket.org

– RESPONSE –

HTTP/1.1 101 Web Socket Protocol Handshake

Access-Control-Allow-Credentials: true

Access-Control-Allow-Headers: content-type

Access-Control-Allow-Headers: authorization

Access-Control-Allow-Headers: x-websocket-extensions

Access-Control-Allow-Headers: x-websocket-version

Access-Control-Allow-Headers: x-websocket-protocol

Access-Control-Allow-Origin: echo.websocket.org

Connection: Upgrade

Date: Tue, 31 Jul 2018 09:02:21 GMT

Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=

Server: Kaazing Gateway

Upgrade: websocket

q).echo.h"hello"

q)“hello”

This can be run without the verbose flag, the purpose of this is to log the request and response to the console. 

I hope this helps,

Julia

I would like to highlight that HTTP_PROXY should be used in the ws.q example to show that the output is being sent to the proxy instead of directly to the server. For example,

$ echo $HTTP_PROXY 

http://127.0.0.1:33207