Hi there,

I'm using curl++ to create a client library for a service which speaks
HTTP.

If I try to access a header field which does not exist in my response
(eg. COntent-Type), curl_easy_getinfo signals this by returning a NULL
pointer.

But

  std::string ret = curlpp::infos::ContentType().get(curlRequest);

cannot return a NULL pointer :)

If a header field did not exist, it caused crashes because the
InfoTypeConverter<std::string> did not handle this case properly. I
fixed this by handeling the NULL pointer cause explicitely there

template<>
void
InfoTypeConverter<std::string>::get(curlpp::Easy & handle,
                      CURLINFO info,
                      std::string & value)
{
  char * tmp;
  InfoGetter::get(handle, info, tmp);
  if (tmp)
    value = tmp;
  else
    value.clear();
}

But I'm not sure if this is the right way. Is there any possibility to
check whether a header field exists or not?

Regards,

Ronny

-- 
You received this message because you are subscribed to the Google Groups 
"curlpp" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/curlpp?hl=en.

Reply via email to