Zinc as a proxy ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Zinc as a proxy ?

marten
Can a Zinc http-server be used as a local proxy ? Had anyone done this ?


Marten Feldtmann

Reply | Threaded
Open this post in threaded view
|

Re: Zinc as a proxy ?

NorbertHartl

Am 31.12.2013 um 13:19 schrieb [hidden email]:

> Can a Zinc http-server be used as a local proxy ? Had anyone done this ?
>
It certainly can. If you add a request handler to your server it gets everything being requested. So you can dispatch it in a way whatever you mean by local proxy. But I’m not aware of any piece of code that does that already. What do you need exactly?

Norbert


Reply | Threaded
Open this post in threaded view
|

Re: Zinc as a proxy ?

Sven Van Caekenberghe-2
In reply to this post by marten
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.org
http://association.pharo.org
http://consortium.pharo.org





Reply | Threaded
Open this post in threaded view
|

Re: Zinc as a proxy ?

marten
The main idea was:

 -> Use Pharo as a headless server
 -> Pharo serves files for a local user (one person application)
 -> GUI is written in Sencha (js framework)
 -> Pharo offers additonal (platform) REST-API's for this application
    and is able to proxy requests for external services (to get
    ONE-source targets for browser apps)
 -> now put all stuff together via an installer and deliver this to
    customers
 -> GUI   is done via alredy installed browser.

The main concept has already be done by me via VASmalltalk (and jQuery
apps) - under Linux and windows - and it worked. (As an platform
REST-API I created a service for ZeroMQ for service detection and IPC
communication).

Now I want to switch to Pharo and Zinc (no need for Seaside any more) -
and be able to offer solutions for Mac, Linux and Windows.

That's were I would like to go ...

Thanks for your answer ...


Marten