Curl gives 404

I added this code for debugging:
std::cout << url.str().c_str();
std::cout << "<br><br>";
std::cout << content.str();

Output:
https://www.ups.com/ups.app/xml/Rate
Error 404--Not Found

When I open that in my browser, though, it appears to be OK. Any ideas?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
int CWebGrabber::GetSSLURLPost(std::string host, unsigned int port,
          std::string urlin, std::stringstream& content,
      std::string postdata, std::string referer)
{
  CurlMemory chunk;
  chunk.memory = NULL;
  chunk.size = 0;

  std::stringstream url;
  url << "https://";
  url << host;
  url << urlin;

  CURL* curl = curl_easy_init();
  curl_easy_setopt(curl, CURLOPT_URL, url.str().c_str());
  curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCurlData);
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunk);
  curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.5");
  curl_easy_setopt(curl, CURLOPT_REFERER, referer.c_str());
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postdata.c_str());
  curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, postdata.size());
  curl_easy_setopt(curl, CURLOPT_POST, 1L);
  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);

  const int timeout = 30000;
  curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout/1000);

  CURLcode curlError = curl_easy_perform(curl);
  curl_easy_cleanup(curl);

  if (chunk.memory)
  {
    content << chunk.memory;
    free(chunk.memory);
    chunk.memory = NULL;
  }
std::cout << "<br><br>";
std::cout << url.str().c_str();
std::cout << "<br><br>";
std::cout << content.str();

  if (content.str().size() == 0)
  {
    std::stringstream error;
    error << "Could not load " << url.str();
    error << ".  Error message = " << curl_easy_strerror(curlError);
    throw std::runtime_error(error.str());
  }

  return content.str().size() > 0; 
I think I could figure it out if I could output the raw CURL Post request and the raw response. Any ideas how to do this?
Topic archived. No new replies allowed.