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

HTLoadAnchorToChunk help - correction

From: Vipul Doshi <v_doshi@hotmail.com>
Date: Tue, 6 Jul 1999 20:07:32 -0400 (EDT)
Message-ID: <19990707000726.75643.qmail@hotmail.com>
To: www-lib@w3.org
Hi,
Some additional information about my problem:

Code on NT4.0, VC++:

// libwwwtest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "libwwwtest.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#include "WWWLib.h"
#include "WWWHTTP.h"
#include "WWWInit.h"
#ifdef __cplusplus
   extern "C" {            /* Start extern C declarations */
#endif
	#include "HTInit.c"
	#include "HTProfil.c"
	#include "HTBInit.c"

#ifdef __cplusplus
   }                       /* End extern C declarations */
#endif

void getdata();

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		nRetCode = 1;
	}
	else
	{


		HTProfile_newClient("TestApp", "1.0");

   		getdata();

		getdata();

		HTProfile_delete();

		}

	return nRetCode;
}

void getdata()
{

	HTRequest * request = HTRequest_new();
   	char * url = "http://vipul/work/AMDSfromUPC.asp";


    HTRequest_setOutputFormat(request, WWW_SOURCE);

    HTRequest_setPreemptive(request, YES);

	char * cwd = HTGetCurrentDirectoryURL();
	char * absolute_url = HTParse(url, cwd, PARSE_ALL);
	HTAnchor * anchor = HTAnchor_findAddress(absolute_url);
	HTChunk * chunk = HTLoadAnchorToChunk(anchor, request);

	HT_FREE(absolute_url);
	HT_FREE(cwd);


	if (chunk) {
	    char * string = HTChunk_toCString(chunk);
		printf("%s", string ? string : "no text");
	    HT_FREE(string);
	}

    HTFormat_deleteAll();
	HTRequest_delete(request);

}

Output from the program:

>Looking up vipul
>Contacting vipul
>Reading...
>BODY:BEGIN
>ERROR:NORECORDS
>BODY:END

--- Above output when getdata function is executed first time ----

>Read (927% of 1K)
>HTTP/1.1 200 OK
>Server: Microsoft-IIS/4.0
>Date: Wed, 07 Jul 1999 00:00:57 GMT
>CONTENT-LENGTH: 36
>Content-Type: text/html
>Expires: Wed, 07 Jul 1999 00:00:57 GMT
>Set-Cookie: ASPSESSIONIDGQGGQQNL=AAHNCOBBHPCFMNHMBOJGCFGO; path=/
>Cache-control: private
>Transfer-Encoding: chunked

>24
>BODY:BEGIN
>ERROR:NORECORDS
>BODY:END

>0

----- Above output when second time getdata is executed ---

The second time around I should just see:

>BODY:BEGIN
>ERROR:NORECORDS
>BODY:END

But I get all the Header information as well.

Please help.. I very new to using libwww.

Thanks

Vipul Doshi


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com
Received on Wednesday, 7 July 1999 03:02:16 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:16 UTC