Hi Marten,
On 31 Dec 2013, at 13:19,
[hidden email] wrote:
> Can a Zinc http-server be used as a local proxy ? Had anyone done this ?
>
>
> Marten Feldtmann
It is not a part of Zinc and I haven’t tried it yet, but yes it can be done. Thanks for asking, it is an interesting use case !
A transparant, forwarding HTTP proxy is a server that accepts HTTP requests to be proxied. Since in HTTP 1.1 a request is self-describing with the required host header and independent of the server that receives it, all the server has to do is execute the request itself, take the response and use that as its own request handling response. With Zinc HTTP Components being an framework implementing both client and server functionality, we can express this behaviour very elegantly:
(ZnServer defaultOn: 8090)
logToTranscript;
debugMode: true;
onRequestRespond: [ :request |
ZnClient new
request: request;
execute;
response ];
start.
Configure one of your browsers to use localhost:8090 as HTTP or web proxy and this should work.
Now, you will notice some problems. There is a bug with gzip compressed responses. And since Zinc fully parses and interpretes requests and responses into an object mode, some issues can come up. Some of those might be bugs, I still have to investigate. Like I said: this is a very interesting use case that will help in further debugging Zinc.
Of course, there is much more to HTTP proxies than this, but basically this is it.
Regards,
Sven
--
Sven Van Caekenberghe
Proudly supporting Pharo
http://pharo.orghttp://association.pharo.orghttp://consortium.pharo.org