[Prev][Next][Index][Thread]

problem posting a document asis



I've been working on what I think should be a trivial application of
libwww which has its own section in the documentation, saving a
document ASIS (Method = POST).  I've made some slight modifications to
the chunk.c example, and the target URL is a perl script that simply
saves stdin to a file.

    cwd = HTGetCurrentDirectoryURL();
    src_url = HTParse(src, cwd, PARSE_ALL);
    HTAnchor * srcAnchor = HTAnchor_findAddress(src_url);

    HTParentAnchor * parAnchor = HTAnchor_parent(srcAnchor);
    HT_FREE(src_url);

      /* Gather information about the source */
    char* full_path = HTParse(src, cwd, PARSE_PATH);
    HTAnchor_setDocument (parAnchor, full_path);
    HTAnchor_setLength(parAnchor, buf.st_size);
    HT_FREE(full_path);
    HT_FREE(cwd);

      /* Set up the request and pass it to the Library */
    HTRequest_setPreemptive(request, YES);
    HTRequest_setMethod(request, METHOD_POST);

    char* target_url = "http://myserver:8080/cgi-bin/saveit";
    HTAnchor * targAnchor = HTAnchor_findAddress(target_url);
    HTAnchor_setAllow((HTParentAnchor*) targAnchor, METHOD_POST);

      /* post the request to absolute URL */
    HTPostAbsolute(parAnchor, target_url, request);

The post fails because the posting data blocks.  Here's some trace
output:

Tee......... Created stream 116198 with resolver 9b2f8
HTTP........ Dumping request to `w3chttp.out'
Posting Data from callback function
HTTP........ Generating Request Headers
HTTP........ Generating General Headers
MIME........ Generating Entity Headers
Write Socket 193 bytes written to socket 5
Writing...
MIME........ Sleeping for 2 secs
Posting Data Target WOULD BLOCK

The dumped request looks correct, but I have not been able to get
around the would block error.  I've also tried making the request
non-blocking, but then the connect fails.

Any assistance would be greatly appreciated.


--
Caleb T. Deupree
cdeupree@erinet.com
;; standard disclaimers apply