has_valid_version.c 460 Bytes
#include <string.h>

#include "http/message.h"

int
httpMessageHasValidVersion(HttpMessage this)
{
	int major;
	int minor;

	if (NULL == this->version)
		return 0;

	if (8 > strlen(this->version))
		return 0;

	if (0 > httpMessageGetVersion(this, &major, &minor))
		return 0;

	if (0 != memcmp("HTTP/", this->version, sizeof("HTTP/")-1))
		return 0;

	if (1 != major)
		return 0;

	if (0 > minor || 1 < minor)
		return 0;

	return 1;
}

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