has_keep_alive.c 496 Bytes
#include <string.h>
#include <ctype.h>

#include "http/request.h"
#include "http/header.h"


char
httpRequestHasKeepAlive(HttpRequest request)
{
	char *  header;
	char *  header_ptr;

	header = httpHeaderGet(request->header, request->nheader, "connection");

	if (NULL == header) {
		return 0;
	}

	for (header_ptr = header; 0 != *header_ptr; header_ptr++) {
		*header_ptr = tolower(*header_ptr);
	}

	if (0 == strcmp(header, "keep-alive")) {
		return 1;
	}

	return 0;
}

// vim: set ts=4 sw=4: