Re: reuse HTRequest

On Tue, Sep 02, 2003 at 06:03:19PM -0700, Jerry G. Chiuan wrote:
> I would like to reuse HTRequest to keep sending data, e.g.

Ah, interesting, I hadn't noticed that HTRequest_clear() exists!

In my code, I have been successful in reusing HTRequest objects. When doing
this, make sure to reset any altered attributes to their defaults. For
example, if you add extra headers sometimes (pragma no-cache, if-mod-since,
ranges etc), remove them again.

Some snippets - pragma no-cache:

  if (pragmaNoCache)
    HTRequest_addGnHd(request, HT_G_PRAGMA_NO_CACHE);
  else
    HTRequest_setGnHd(request, static_cast<HTGnHd>(HTRequest_gnHd(request)
                                                   & ~HT_G_PRAGMA_NO_CACHE));

Ranges:

  HTRequest_deleteRange(request); // Delete old range, if any
  HTRequest_addRange(request, "bytes", "1234-"); // Add new range

Cheers,

  Richard

PS: Please don't quote entire completely unrelated postings at the bottom 
of your mail.
-- 
  __   _
  |_) /|  Richard Atterer     |  GnuPG key:
  | \/¯|  http://atterer.net  |  0x888354F7
  ¯ '` ¯

Received on Wednesday, 3 September 2003 15:19:31 UTC