view src/lib-http/http-request.c @ 22638:7d5634889da8

lib: net_ip2addr() - Optimize by allocating destination memory immediately It doesn't really matter if we allocate a few extra bytes.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sat, 04 Nov 2017 01:42:37 +0200
parents 219ec946f7c3
children cb108f786fb4
line wrap: on
line source

/* Copyright (c) 2013-2017 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "array.h"
#include "istream.h"

#include "http-request.h"

bool http_request_has_connection_option(const struct http_request *req,
	const char *option)
{
	const char *const *opt_idx;

	if (!array_is_created(&req->connection_options))
		return FALSE;
	array_foreach(&req->connection_options, opt_idx) {
		if (strcasecmp(*opt_idx, option) == 0)
			return TRUE;
	}
	return FALSE;
}

int http_request_get_payload_size(const struct http_request *req,
	uoff_t *size_r)
{
	if (req->payload == NULL) {
		*size_r = 0;
		return 1;
	}

	return i_stream_get_size(req->payload, TRUE, size_r);
}