Revision 0bfdcc3a peerstreamer-ng.c

View differences:

peerstreamer-ng.c
53 53
		}
54 54
}
55 55

  
56
void mg_request_decode(char * buff, int buff_len, const struct http_message *hm)
57
{
58
	size_t i = 0;
59

  
60
	if (buff_len - i -2 > hm->method.len)
61
	{
62
		memmove(buff + i, hm->method.p, hm->method.len);
63
		i += hm->method.len;
64
	}
65
	buff[i++] = ' ';
66
	if (buff_len - i -2 > hm->uri.len)
67
	{
68
		memmove(buff + i, hm->uri.p, hm->uri.len);
69
		i += hm->uri.len;
70
	}
71
	buff[i++] = ' ';
72
	if (buff_len - i -1 > hm->query_string.len)
73
	{
74
		memmove(buff + i, hm->query_string.p, hm->query_string.len);
75
		i += hm->query_string.len;
76
	}
77
	buff[i] = '\0';
78
}
79

  
56 80
void ev_handler(struct mg_connection *nc, int ev, void *ev_data)
57 81
{
58 82
	struct context *c = nc->user_data;
59 83
	struct http_message *hm;
84
	char buff[80];
60 85

  
61 86
	switch (ev) {
62 87
		case MG_EV_HTTP_REQUEST:
63 88
			hm  = (struct http_message *) ev_data;
89
			debug("Received a request:\n");
90
			mg_request_decode(buff, 80, hm);
91
			debug("\t%s\n", buff);
64 92
			// Try to call a path handler. If it fails serve
65 93
			// public contents
66 94
			if(router_handle(c->router, nc, hm))

Also available in: Unified diff