W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2001

RE: https over proxy patch

From: Grushinskiy, Mikhail, NNAD <mgrushinskiy@att.com>
Date: Thu, 26 Jul 2001 11:07:06 -0400
Message-ID: <177C519EE5CCD31195390090278539D30546B406@njb140po04.ems.att.com>
To: Karl-Otto Linn <linn@informatik.fh-wiesbaden.de>, www-lib@w3.org
Try this. I used to test some stuff with this sample.
It could show some ideas, but I haven't tried to run it for a while.

 <<post.c>>  
--Mikhail

> -----Original Message-----
> From:	Karl-Otto Linn [SMTP:linn@informatik.fh-wiesbaden.de]
> Sent:	Thursday, July 26, 2001 5:28 AM
> To:	Grushinskiy, Mikhail, NNAD
> Subject:	Re: https over proxy patch
> 
> Hi Mikhail,
> I'am also intested to get https to work over a proxy connection.
> I have an additional question: Can you send me a sample main programm
> (like wwwssl.c) doing a post request?
> I'am trying https with and without proxy. The get-requests work - at least
> without proxy , but the post requests don't - my programm
> hangs.
> Thank you
> Karl-Otto
> 
> "Grushinskiy, Mikhail, NNAD" wrote:
> > 
> > Isn't it HTERR_SYSTEM error? It seems your program is failing
> > on connect() call.
> > 
> > Here is the line in HTTCP.c
> > 
> >   HTRequest_addSystemError(request, ERR_FATAL, socerrno, NO, "connect");
> > 
> > Are you sure you can at least connect (with let's say telnet)
> > to this port on your proxy? You could use a sniffer like ethereal
> > to see what is actually going on.
> > 
> > Are you trying to use https port of your proxy?
> > Actually this should work with another port (regular http proxy
> > which supports CONNECT). Your proxy doesn't have to know
> > about SSL. After connect it works as a tunnel.
> > Try to use your HTTP port of your proxy instead of https.
> > 
> > I've managed to make my program work with both POST and GET
> > with https via proxy. I also used purify and found huge memory leaks
> > in this patch, and some other memory violations.
> > 
> > Here is the list:
> > 
> > 1. HTChannl.c free_channel() - freeing unallocated memory
> > htssl is deleted in isa->close() functions before
> > 
> >         /* https-proxy */
> >         if (ch->htssl) {
> >             /* deleted in isa->close methods  */
> >             /* HTSSL_free(ch->htssl); */ /*MMMMM*/
> >             ch->htssl = NULL;
> >         }
> > 
> > 2. HTHost.c
> > 
> > This is a really huge memory leak ~32K per request.
> > 
> > I've added
> > 
> > /*MMMMM*/
> > struct _HTOutputStream {
> >      const HTOutputStreamClass *  isa;
> > };
> > 
> > after similar lines for _HTInputStream in HTHost.c
> > 
> > and
> > 
> > modified one TODO section
> > 
> >          HTChannel * ch = HTHost_channel(me);
> >          if (ch)  {
> >              /* TODO: release input && output rather then setting to
> NULL */
> >              HTTRACE(PROT_TRACE, "HTHost  deleting old input & output");
> > 
> >              /*MMMMM*/
> >              HTChannel_deleteInput(ch, HT_INTERRUPTED);
> >              HTChannel_deleteOutput(ch, HT_INTERRUPTED);
> > 
> >              HTChannel_input(ch)->isa->close(HTChannel_input(ch));
> >              HTChannel_output(ch)->isa->close(HTChannel_output(ch));
> > 
> >              HTChannel_setInput(ch, NULL);
> >              HTChannel_setOutput(ch, NULL);
> >          }
> > 
> > This releases input/output streams and fixes leaks.
> > 
> > 3. HTTPReq.c
> > 
> > I also added HT_FREE(me->url); in the following piece in HTTPReq.c
> > This fixed another leak. me->url initially was allocated by HTParse and
> > afterwards overwritten by second HTParse in 'if METHOD_CONNECT'.
> > So the memory allocated by first HTParse was lost. This was also
> > per / request leak.
> > 
> >          else {
> >              me->url = HTParse(addr, "", PARSE_PATH |
> PARSE_PUNCTUATION);
> >              if (method == METHOD_OPTIONS) {
> >                  /*
> >                  ** We don't preserve the final slash or lack of same
> > through
> >                  ** out the code. This is mainly for optimization
> reasons
> >                  ** but it gives a problem OPTIONS. We can either send a
> "*"
> >                  ** or a "/" but not both. For now we send a "*".
> >                  */
> >                  if (!strcmp(me->url, "/")) *me->url = '*';
> >              }
> >              else if (method == METHOD_CONNECT) {
> >                HT_FREE(me->url); /*MMMMM*/
> >                  me->url = HTParse(addr, "", PARSE_HOST );
> >                  if (!strchr(me->url, ':'))
> >                    StrAllocCat(me->url, ":443");
> >              }
> > 
> > Another problem I had was an infinite loop on READ / WRITE without
> > invoking select(). I've found a fix which works for me, but I'm not so
> sure
> > whether it is absolutely correct.
> > 
> > In HTHost.c HostEvent() function there is:
> > 
> > if (targetNet) {
> >   HTTRACE(CORE_TRACE, "Host Event.. READ passed to `%s\'\n" _
> >       HTAnchor_physical(HTRequest_anchor(HTNet_request(targetNet))));
> >       if ((ret =
> (*targetNet->event.cbf)(HTChannel_socket(host->channel),
> >                     targetNet->event.param, type)) != HT_OK)   return
> ret;
> > }
> > 
> > I've changed it to:
> > 
> > if (targetNet) {
> >   HTTRACE(CORE_TRACE, "Host Event.. READ passed to `%s\'\n" _
> >       HTAnchor_physical(HTRequest_anchor(HTNet_request(targetNet))));
> >       if ((ret =
> (*targetNet->event.cbf)(HTChannel_socket(host->channel),
> >                     targetNet->event.param, type)) != HT_OK)
> >             HTTRACE(CORE_TRACE, "Host Event.. READ passed Before
> RETURN\n");
> > /*MMMMM*/
> >       return ret;
> > }
> > 
> > so  it always returns "ret" in that place. This fixed endless loop in
> > SSLReader/SSLWriter for me.
> > 
> > To make POST work I had to restore entityAnchor after CONNECT and before
> > POST.
> > The entity anchor probably should be saved in a way similar to
> > HTRequest_saveOrigMethod/
> > HTRequest_origMethod. I did it in my program code and it works, however
> > generic
> > change should be probably made in libwww.
> > 
> > I hope this will help somebody...
> > 
> > --Mikhail
> >


Received on Thursday, 26 July 2001 11:07:50 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:39 GMT