W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2003

HTRequest -- making multiple requests

From: John Chapman <john_chapman@wsu.edu>
Date: Thu, 02 Jan 2003 15:04:17 -0800
Message-Id: <>
To: www-lib@w3.org

We are using the HTRequest family of functions to try and make multiple
calls to a server.We have it working fine just sending one call to the
server and closing the connection. But there are times we'd like to send
several chunks to the server and receive chunks back. This is what we
are doing that is working fine for a single call. We tried changing the
HTRequest_addConnection to change the second parameter to "Keep-Alive"
instead of "close" in the hopes that would keep it open. But we still
could only send one chunk to the server. How do we change this to allow
multiple calls to the server?

#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/uswitch.h>
#include <time.h>
#include <netinet/in.h>
#include <stdlib.h>
#include "xmlrpc.h"

HTChunk * chunk = NULL;

PRIVATE int printer (const char *fmt, va_list pArgs) {}
PRIVATE int tracer (const char *fmt, va_list pArgs) {}

PUBLIC HTChunk * PostAnchorToChunk (HTParentAnchor *    source,
                          HTAnchor *             destination,
                          HTRequest *            request)

     if (source && destination && request) {
         HTChunk * chunk = NULL;
         HTStream * target = HTStreamToChunk(request, &chunk, 0);

         HTRequest_setOutputStream(request, target);
         if ( HTPostAnchor(source, destination, request ) != NULL ) {
              return chunk;
         else {
              return NULL;
     return NULL;

PRIVATE int terminate_handler (HTRequest * request, HTResponse *
                                void * param, int status)
    return HT_OK;

void process_echeck (char *state,  char *inmerch, char *intrantyp, char
*inpymtopt, char *inbtn,
                      char *inacct,char *incsind, char *inamount, char
*inpersonid, char *inname,
                      char *inbrowserip, char *rtncode, char *rtnmessage,
char *rtnseqnum, char *rtnamount)
         int length, start, intVal;

         HTRequest * request = NULL;
         HTParentAnchor * src = NULL;
         HTAnchor * dst = NULL;

         char * dst_str = "http://itnt104.it.wsu.edu/xml-rpc/echeck.asp";
         char * returnBuf;
         char * OutBuf;
         char * returnBuf2;
         char * string;
         char * merch;


     /* Create a new premptive client */

     /* Add our own filter to update the history list */
         HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL,

     /* Set the timeout for long we are going to wait for a response */
     /*      xmlbuf is our routine to put the parms into XML.
             not included here to save space */
         OutBuf = (char*) strdup(xmlbuf(inmerch, intrantyp, inpymtopt,
inbtn, inacct,
         incsind, inamount, inpersonid, inname, inbrowserip));
         request = HTRequest_new();
         HTRequest_setOutputFormat(request, WWW_RAW);

         dst = HTAnchor_findAddress(dst_str);
         src = HTTmpAnchor(NULL);
         HTAnchor_setDocument(src, OutBuf);
         HTAnchor_setLength(src, strlen(OutBuf));

         chunk = PostAnchorToChunk(src, dst, request);

         if (chunk) {
                 returnBuf = strdup(HTChunk_toCString(chunk));

         length = (int)strlen(returnBuf);
         start = string_index(returnBuf,"<?xml ");

         length = length - start;
         returnBuf = substr(returnBuf, start, length);


John Chapman
Information Technology          (509) 335-7350 (voice)
Washington State University     (509) 335-0540 (fax)
john_chapman@wsu.edu          (509) 336-4100 (pager)
Received on Thursday, 2 January 2003 17:55:21 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:55 UTC