Ejemplo n.º 1
0
/**
 * Delayed RPC start.
 */
static void
soap_rpc_launch(cqueue_t *unused_cq, gpointer obj)
{
	soap_rpc_t *sr = obj;
	http_post_data_t post;

	(void) unused_cq;
	soap_rpc_check(sr);

	sr->delay_ev = NULL;

	if (GNET_PROPERTY(soap_debug) > 4) {
		g_debug("SOAP \"%s\" at \"%s\": launching (%s)",
			sr->action, sr->url, sr->retry ? "retry" : "initial");
	}

	sr->reply_len = 0;		/* In case we retry, clear out older data */

	/*
	 * Launch the asynchronous POST request.
	 */

	post.content_type = SOAP_CONTENT_TYPE;
	post.data = pmsg_start(sr->mb);
	post.datalen = pmsg_size(sr->mb);
	post.data_free = NULL;
	post.data_free_arg = NULL;

	sr->ha = http_async_post(sr->url, &post, soap_header_ind,
				soap_data_ind, soap_error_ind);

	/*
	 * If we cannot create the HTTP request, it can be the URL is wrong,
	 * or no connection can be established to the host.  Hence it's a
	 * contacting error, not an I/O error at this stage.
	 */

	if (sr->ha == NULL) {
		if (GNET_PROPERTY(soap_debug)) {
			g_warning("SOAP cannot contact \"%s\": %s",
				sr->url, http_async_strerror(http_async_errno));
		}
		soap_error(sr, SOAP_E_CONTACT);
		return;
	}

	/*
	 * Customize the HTTP layer.
	 */

	http_async_set_opaque(sr->ha, sr, NULL);
	http_async_set_op_post_request(sr->ha, soap_build_request);
	http_async_set_op_headsent(sr->ha, soap_sent_head);
	http_async_set_op_datasent(sr->ha, soap_sent_data);
	http_async_set_op_gotreply(sr->ha, soap_got_reply);
	http_async_option_ctl(sr->ha, HTTP_O_READ_REPLY, HTTP_CTL_ADD);
}
Ejemplo n.º 2
0
/**
 * Allocate new parsing context for handle and record it.
 *
 * @param `handle'		the asynchronous HTTP request handle.
 * @param `maxlines'	the max number of lines we want to parse.
 */
static void
parse_context_set(void *handle, int maxlines)
{
	struct parse_context *ctx;

	WALLOC(ctx);
	ctx->getline = getline_make(GHC_MAX_LINE_LEN);
	ctx->maxlines = maxlines;
	ctx->handle = handle;
	ctx->lines = 0;
	ctx->processed = 0;

	http_async_set_opaque(handle, ctx, parse_context_free);
}
Ejemplo n.º 3
0
/**
 * Allocate new parsing context for handle and record it.
 *
 * @param `handle'		the asynchronous HTTP request handle.
 * @param `maxlines'	the max number of lines we want to parse.
 */
static void
gwc_parse_context_set(void *handle, int maxlines)
{
    struct gwc_parse_context *ctx;

    ctx = walloc(sizeof(*ctx));
    ctx->getline = getline_make(MAX_LINE_SIZE);
    ctx->maxlines = maxlines;
    ctx->handle = handle;
    ctx->lines = 0;
    ctx->processed = 0;

    http_async_set_opaque(handle, ctx, gwc_parse_context_free);
}