Re: Problems with POST

Isabelle,

Isabelle Delagarde wrote:

> I would like to POST data with format "a=b&c=d&..." followed by a MIME
> file : everything needs to be in the same request.

I've digged into the library's code, and haven't found how to do this
(elegantly) either -although I would think it is supported, as my reading of
the latest HTTP draft is that this is a perfectly legal operation...

Please find below a patch to apply to ComLine/src/HTLine.c, which is my
closest attempt at implementing this functionality in the w3c sample program
(which I believe did not implement the '-post -dest' option properly).

Of course, any further help on this topic will be appreciated!

Jean-Jacques.

PS. Sorry for not providing a patch file; I am compiling under Win98/Cygnus!

------------------------------------------------------------
    case METHOD_POST:
 if (formdata) {
     HTParentAnchor * posted = NULL;
#if 1
     posted = HTPostFormAnchor(formfields, (HTAnchor *) cl->anchor,
          cl->request);
     status = posted ? YES : NO;
#else
     /* If we want output to a chunk instead */
     post_result = HTPostFormAnchorToChunk(formfields, (HTAnchor *)
cl->anchor,
        cl->request);
     status = post_result ? YES : NO;
#endif
 } else {
#if 0
     if (SHOW_MSG) HTPrint("Nothing to post to this address\n");
     status = NO;
#else
     FILE * stream;
     char postString[4096];

     char * postDataURL = HTAnchor_address((HTAnchor *) cl->anchor);
     char * tail = strrchr(postDataURL, '/') + 1;
     stream = fopen(tail, "r");
     fread(postString, sizeof(char), 4096, stream);
     fclose(stream);

     HTAnchor_clearHeader(cl->anchor);
     HTAnchor_setDocument(cl->anchor, postString);
     HTAnchor_setLength(cl->anchor, strlen(postString));
     HTAnchor_setFormat(cl->anchor, WWW_RAW);

     HTLink_removeAll((HTAnchor *) cl->anchor);
     HTLink_add((HTAnchor *) cl->anchor, (HTAnchor *) cl->dest,
         NULL, METHOD_POST);

     status = HTPostAnchor(cl->anchor, (HTAnchor *) cl->dest,
          cl->request);

#endif
 }
 break;

Received on Tuesday, 2 March 1999 10:52:32 UTC