test-http-client.c revision cca4ba2a504d70a9fe9fee37f8433997359de52c
#include "lib.h"
#include "ioloop.h"
#include "istream.h"
#include "write-full.h"
#include "http-client.h"
struct http_test_request {
};
{
const unsigned char *data;
int ret;
/* read payload */
//write_full(1, data, size);
}
if (ret == 0) {
i_info("DEBUG: REQUEST: NEED MORE DATA");
/* we will be called again for this request */
} else {
i_error("REQUEST PAYLOAD READ ERROR: %m");
else
i_info("DEBUG: REQUEST: Finished");
}
}
static void
struct http_test_request *req)
{
/* request failed */
i_error("HTTP REQUEST FAILED");
return;
}
/* payload (if any) is skipped implicitly */
return;
}
return;
}
i_info("DEBUG: REQUEST: Got payload");
payload_input, req);
}
static const char *test_query1 = "data=Frop&submit=Submit";
static const char *test_query2 = "data=This%20is%20a%20test&submit=Submit";
static const char *test_query3 = "foo=bar";
int main(void)
{
struct http_client_settings http_set;
struct http_client *http_client;
struct http_client_request *http_req;
struct http_test_request *test_req;
struct istream *post_payload;
lib_init();
ioloop = io_loop_create();
// JigSAW is useful for testing: http://jigsaw.w3.org/HTTP/
"GET", "pigeonhole.dovecot.org", "/",
"GET", "jigsaw.w3.org", "/HTTP/300/301.html",
"GET", "jigsaw.w3.org", "/HTTP/300/307.html",
"GET", "jigsaw.w3.org", "/HTTP/300/302.html",
"Content-Type", "application/x-www-form-urlencoded");
"Content-Type", "application/x-www-form-urlencoded");
"GET", "pigeonhole.dovecot.org", "/",
"GET", "pigeonhole.dovecot.org", "/",
"GET", "wiki2.dovecot.org", "/Pigeonhole",
"POST", "jigsaw.w3.org", "/HTTP/300/Go_307",
"POST", "jigsaw.w3.org", "/HTTP/300/Go_307",
"POST", "jigsaw.w3.org", "/HTTP/300/Go_307",
lib_deinit();
}