Jump to content
alank2

How to clear the TNetHTTPClient.CustomeHeaders ?

Recommended Posts

This is for C++ Builder, but I would think there is a Delphi way to do it that would translate, so I'm asking how you would clear it in Delphi and/or cppb.

 

It says it is "Property Customheaders:UnicodeString", but I can't set it using:

 

nhc->CustomHeaders="";

 

I am setting it using:

 

nhc->CustomHeaders[name]=value;

 

But, if I want to clear out any custom headers and start again, how do I do that?

 

Share this post


Link to post

Unfortunately there is no Clear() method.  When I try to see what the methods are and type c, this is all it shows:

 

image.png.7a6e0509db47caf85afb30fd8bc7d46e.png

Share this post


Link to post
Posted (edited)

The CustomHeaders property is an indexed property.  It is used only to read/write individual headers by name.  You are seeing the methods of a single UnicodeString instance. There is no option to clear the whole list using the CustomHeaders property.

 

However, you can use the CustHeaders property instead (not to be confused with the CustomHeaaders property!). It gives you access to the whole list, and it has a Clear() method:

nhc->CustHeaders->Clear();
// NOT nhc->CustomHeaders->Clear(),
// which does not exist....

 

Edited by Remy Lebeau
  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×