Beispiel #1
0
static char *dump_buffer(char *buf, int length)
{
	struct httpddata *hd;
	char buf1[300];

	hd = current_cptr->userdata;
	snprintf(buf1, sizeof buf1, "HTTP/1.1 200 OK\r\n"
			"%s"
			"Server: Atheme/%s\r\n"
			"Content-Type: text/xml\r\n"
			"Content-Length: %d\r\n\r\n",
			hd->connection_close ? "Connection: close\r\n" : "",
			PACKAGE_VERSION, length);
	sendq_add(current_cptr, buf1, strlen(buf1));
	sendq_add(current_cptr, buf, length);
	if (hd->connection_close)
		sendq_add_eof(current_cptr);
	return buf;
}
Beispiel #2
0
int raw(char *line, ...)
{
    char sendbuf[510];
    int length;
    va_list args;

    va_start(args, line);
    vsnprintf(sendbuf, 509, line, args);
    va_end(args);

    strlcat(sendbuf, "\r\n", 2);
    length = strlen(sendbuf);

    sendq_add(me.uplink.sock, sendbuf, length); 
    strip(sendbuf, "\r\n");
    logger(LOG_RAW, "<< %s", sendbuf);
    return length;
}
Beispiel #3
0
void http_write_GET(connection_t *cptr)
{
	mowgli_node_t *n, *tn;
	http_client_t *container = NULL;
	char buf[BUFSIZE];
	size_t len;

	if (!(container = cptr->userdata))
		return;

	len = snprintf(buf, BUFSIZE,
			"GET %s%s HTTP/1.1\r\n"
			"User-Agent: Atheme/%s\r\n"
			"Host: %s\r\n"
			"Accept: */*\r\n"
			"\r\n",
			container->uri,
			container->query_string,
			PACKAGE_VERSION,
			container->domain);
	sendq_add(cptr, buf, len);
}
static void do_packet(connection_t *cptr, char *buf)
{
        char *ptr, buf2[BUFSIZE * 2];
        static char tmp[BUFSIZE * 2 + 1];

        while ((ptr = strchr(buf, '\n')))
        {
                snprintf(buf2, (BUFSIZE * 2), "%s%s", tmp, buf);
                *tmp = '\0';

		slog(LG_DEBUG, "-{incoming}-> %s", buf2);
		sendq_add(cptr, buf2, strlen(buf2));

                buf = ptr + 1;
        }

        if (*buf)
        {
                mowgli_strlcpy(tmp, buf, BUFSIZE * 2);
                tmp[BUFSIZE * 2] = '\0';
        }
}