Beispiel #1
0
void http_gen_cb(evutil_socket_t fd, short events, void *arg)
{
	int ret = 0;
	struct http_connection *hc = (struct http_connection *)arg;

	http_header_start(hc, 200, "OK", "text/html");
	http_header_clength(hc, strlen(str_http_index_html));
	http_header_end(hc);

	evbuffer_add(hc->evbout, str_http_index_html, strlen(str_http_index_html));

	http_evbuffer_writeout(hc, 0);

	http_connection_free(hc);
}
Beispiel #2
0
static int output_cb_http(struct http_connection *hc, int cbtype, void *arg) {

	switch(cbtype) {
		case(HCB_QUERY): {
			struct http_receiver_s	*hr;
			struct output_s		*o=arg;	/* HCB_QUERY returns http_url args */

			hr=calloc(1, sizeof(struct http_receiver_s));
			hr->hc=hc;
			hr->output=o;

			/* Put into stream output list */
			o->http_receiver=g_list_append(o->http_receiver, hr);
			o->receiver++;

			/* Store http_receiver into http_connection structure */
			hc->arg=hr;

			/* Return head */
			http_header_start(hc, "200 OK", "application/octet-stream");
			http_header_nocache(hc);
			http_header_clength(hc, -1);
			http_header_end(hc);

			logwrite(LOG_INFO, "stream_http: connection from %s for %s",
						inet_ntoa(hc->sin.sin_addr),
						hc->url);
			break;
		}
		case(HCB_ERROR): {
			output_remove_receiver(hc->arg);
			break;
		}
	}
	return 1;
}