summaryrefslogtreecommitdiffabout
path: root/lib/oauth-consumer.cc
Unidiff
Diffstat (limited to 'lib/oauth-consumer.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/oauth-consumer.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/oauth-consumer.cc b/lib/oauth-consumer.cc
index d717ed3..0c4c9e3 100644
--- a/lib/oauth-consumer.cc
+++ b/lib/oauth-consumer.cc
@@ -222,6 +222,34 @@ namespace opkele {
222 t,realm); 222 t,realm);
223 } 223 }
224 224
225 void http_request_t::setup_curl(CURL *curl) {
226 CURLcode r;
227 r = curl_easy_setopt(curl,CURLOPT_URL,url.c_str());
228 if(r)
229 throw exception_curl(OPKELE_CP_ "failed to set curly urlie",r);
230 if(method=="POST") {
231 (r = curl_easy_setopt(curl,CURLOPT_POST,1))
232 || (r = curl_easy_setopt(curl,CURLOPT_POSTFIELDS,body.c_str()))
233 || (r = curl_easy_setopt(curl,CURLOPT_POSTFIELDSIZE,body.size()));
234 }else if(method=="GET") {
235 r = curl_easy_setopt(curl,CURLOPT_HTTPGET,1);
236 }else if(method=="HEAD") {
237 r = curl_easy_setopt(curl,CURLOPT_NOBODY,1);
238 }else /* TODO: specialize exception */
239 throw exception(OPKELE_CP_ "don't know how to handle http method");
240 if(r)
241 throw exception_curl(OPKELE_CP_ "failed to set curly options",r);
242 if(!authorize_header.empty()) {
243 r = curl_easy_setopt(curl,CURLOPT_HTTPHEADER,(curl_slist*)(
244 _curl_headers_list = curl_slist_append(
245 0,string("Authorization: "+authorize_header).c_str()
246 )
247 ) );
248 if(r)
249 throw exception_curl(OPKELE_CP_ "failed to setup curlie header");
250 }
251 }
252
225 253
226 const basic_provider_endpoints& simple_consumer::get_endpoints() const { 254 const basic_provider_endpoints& simple_consumer::get_endpoints() const {
227 return peps; } 255 return peps; }