/[projects]/smsdaemon/HttpClient.cpp
ViewVC logotype

Diff of /smsdaemon/HttpClient.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 195 by torben, Thu Dec 18 06:47:26 2008 UTC revision 196 by torben, Thu Dec 18 06:53:29 2008 UTC
# Line 11  namespace HttpClient Line 11  namespace HttpClient
11          std::string UrlEncode(std::string url)          std::string UrlEncode(std::string url)
12          {          {
13                  std::ostringstream ss;                  std::ostringstream ss;
14                  for (unsigned i=0; i<url.size(); i++) {                  for (unsigned i=0; i<url.size(); i++)
15                    {
16                          char ch = url.at(i);                          char ch = url.at(i);
17                          if (isalnum(ch))                          if (isalnum(ch))
18                                  ss << ch;                                  ss << ch;
# Line 30  namespace HttpClient Line 31  namespace HttpClient
31                  std::vector<char>* vec = reinterpret_cast< std::vector<char>* >(stream);                  std::vector<char>* vec = reinterpret_cast< std::vector<char>* >(stream);
32    
33                  int i;                  int i;
34          for (i=0; i<total; i++)                  for (i=0; i<total; i++)
35          {                                            {
36                  vec->push_back( bytes[i] );                          vec->push_back( bytes[i] );
37          }                  }
38                  return i;                  return i;
39          }          }
40    
# Line 48  namespace HttpClient Line 49  namespace HttpClient
49    
50                  curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errmsg);                  curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errmsg);
51    
52          curl_easy_setopt(curl, CURLOPT_URL, url.c_str() );                  curl_easy_setopt(curl, CURLOPT_URL, url.c_str() );
53          curl_easy_setopt(curl, CURLOPT_FAILONERROR,1);                  curl_easy_setopt(curl, CURLOPT_FAILONERROR,1);
54          curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunction);                  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunction);
55                  curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buf);                  curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buf);
56    
57          int res = curl_easy_perform(curl);                  int res = curl_easy_perform(curl);
58          curl_easy_cleanup(curl);                  curl_easy_cleanup(curl);
59    
60                  if (res != 0)                  if (res != 0)
61                          throw httpexception(errmsg);                          throw httpexception(errmsg);

Legend:
Removed from v.195  
changed lines
  Added in v.196

  ViewVC Help
Powered by ViewVC 1.1.20