Skip to content

Commit

Permalink
Merge branch 'master' into auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cline committed May 28, 2012
2 parents d4ae1a4 + 2d321bf commit a0eaf82
Show file tree
Hide file tree
Showing 5 changed files with 296 additions and 206 deletions.
22 changes: 19 additions & 3 deletions curl_interface.c
Expand Up @@ -34,11 +34,12 @@
* @uri struct str_t* the uri for the initial request
* @header_count size_t the number of elements in headers[]
* @headers struct str_t[] the headers, if any, for this request
* @msg const char* a message for POST, NULL if not POST
* @type enum request_type the type of the request, GET, POST, ...
*/
int ci_init(struct request_t* request, struct str_t* uri,
size_t header_count, const struct str_t const headers[],
enum request_type_e type)
const char const* msg, enum request_type_e type)
{
// TODO: Errors
union func_u func;
Expand All @@ -61,10 +62,25 @@ int ci_init(struct request_t* request, struct str_t* uri,
// set curl_post_callback's last parameter to state
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &request->response);

ret = ci_create_header(request, header_count, headers);
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, request->headers); // Set headers
if(header_count)
{
ret = ci_create_header(request, header_count, headers);
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, request->headers); // Set headers
}

curl_easy_setopt(handle, CURLOPT_USERAGENT, "fuse-google-drive/0.1");

switch(type)
{
case GET:
break;
case POST:
curl_easy_setopt(handle, CURLOPT_POSTFIELDS, msg);
break;
default:
break;
}

request->handle = handle;

ret = ci_set_uri(request, uri);
Expand Down
2 changes: 1 addition & 1 deletion curl_interface.h
Expand Up @@ -79,7 +79,7 @@ struct request_t {

int ci_init(struct request_t* request, struct str_t* uri,
size_t header_count, const struct str_t headers[],
enum request_type_e type);
const char const* msg, enum request_type_e type);
int ci_destroy(struct request_t* request);

int ci_create_header(struct request_t* request,
Expand Down

0 comments on commit a0eaf82

Please sign in to comment.