1 /* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
2 
3 #include "lib.h"
4 #include "array.h"
5 #include "istream.h"
6 
7 #include "http-request.h"
8 
http_request_has_connection_option(const struct http_request * req,const char * option)9 bool http_request_has_connection_option(const struct http_request *req,
10 	const char *option)
11 {
12 	const char *opt;
13 
14 	if (!array_is_created(&req->connection_options))
15 		return FALSE;
16 	array_foreach_elem(&req->connection_options, opt) {
17 		if (strcasecmp(opt, option) == 0)
18 			return TRUE;
19 	}
20 	return FALSE;
21 }
22 
http_request_get_payload_size(const struct http_request * req,uoff_t * size_r)23 int http_request_get_payload_size(const struct http_request *req,
24 	uoff_t *size_r)
25 {
26 	if (req->payload == NULL) {
27 		*size_r = 0;
28 		return 1;
29 	}
30 
31 	return i_stream_get_size(req->payload, TRUE, size_r);
32 }
33