source: mod_gnutls/src/gnutls_util.h @ 235e109

debian/masterdebian/stretch-backportsupstream
Last change on this file since 235e109 was 235e109, checked in by Fiona Klute <fiona.klute@…>, 20 months ago

Unify initialization of mod_gnutls connection context

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  Copyright 2016 Thomas Klute
3 *
4 *  Licensed under the Apache License, Version 2.0 (the "License");
5 *  you may not use this file except in compliance with the License.
6 *  You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *  Unless required by applicable law or agreed to in writing, software
11 *  distributed under the License is distributed on an "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *  See the License for the specific language governing permissions and
14 *  limitations under the License.
15 */
16
17#include <apr_buckets.h>
18#include <apr_lib.h>
19#include <apr_network_io.h>
20#include <apr_pools.h>
21#include <apr_uri.h>
22#include <gnutls/gnutls.h>
23#include "mod_gnutls.h"
24
25#ifndef __MOD_GNUTLS_UTIL_H__
26#define __MOD_GNUTLS_UTIL_H__
27
28/** maximum allowed length of one header line */
29#define HTTP_HDR_LINE_MAX 1024
30
31/**
32 * Create an HTTP header to send a POST request with 'size' bytes of
33 * data to 'uri'.
34 */
35const char* http_post_header(apr_pool_t *p, apr_uri_t *uri,
36                             const char *content_type, const char *accept,
37                             apr_size_t size)
38    __attribute__((nonnull(1, 2, 3)));
39
40/**
41 * Try to transfer one header line from 'sockb' into 'lineb', then
42 * return it from there. The line may be no more than
43 * HTTP_HDR_LINE_MAX bytes long, including the terminating CRLF. CR is
44 * replaced with \0 so the line can be processed as a string without
45 * breaks. 'lineb' is flushed before reading the line. Returns either
46 * a pointer to the line (allocated from 'p'), or NULL in case of an
47 * error.
48 */
49const char* read_line(apr_pool_t *p, apr_bucket_brigade *sockb,
50                      apr_bucket_brigade *lineb)
51    __attribute__((nonnull));
52
53/**
54 * Send 'size' bytes from 'buf' over 'sock', using partial send
55 * operations if necessary. Returns APR_SUCCESS or an APR error code
56 * returned by apr_socket_send().
57 */
58apr_status_t sock_send_buf(apr_socket_t *sock, const char *buf,
59                           const apr_size_t size)
60    __attribute__((nonnull));
61
62/**
63 * Read a file into a gnutls_datum_t, allocate necessary memory from
64 * the pool.
65 */
66apr_status_t datum_from_file(apr_pool_t *p, const char* filename,
67                             gnutls_datum_t *datum)
68    __attribute__((nonnull));
69
70/**
71 * Allocate the connection configuration structure if necessary, set
72 * some defaults.
73 */
74mgs_handle_t *init_gnutls_ctxt(conn_rec *c);
75
76#endif /* __MOD_GNUTLS_UTIL_H__ */
Note: See TracBrowser for help on using the repository browser.