1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 2005 Novell, Inc.
4 */
5
6#ifndef __SOUP_MESSAGE_HEADERS_H__
7#define __SOUP_MESSAGE_HEADERS_H__ 1
8
9#include <libsoup/soup-types.h>
10
11G_BEGIN_DECLS
12
13typedef struct SoupMessageHeaders SoupMessageHeaders;
14SOUP_AVAILABLE_IN_2_4
15GType soup_message_headers_get_type (void);
16#define SOUP_TYPE_MESSAGE_HEADERS (soup_message_headers_get_type ())
17
18typedef enum {
19 SOUP_MESSAGE_HEADERS_REQUEST,
20 SOUP_MESSAGE_HEADERS_RESPONSE,
21 SOUP_MESSAGE_HEADERS_MULTIPART
22} SoupMessageHeadersType;
23
24SOUP_AVAILABLE_IN_2_4
25SoupMessageHeaders *soup_message_headers_new (SoupMessageHeadersType type);
26
27SOUP_AVAILABLE_IN_2_4
28void soup_message_headers_free (SoupMessageHeaders *hdrs);
29
30SOUP_AVAILABLE_IN_2_4
31void soup_message_headers_append (SoupMessageHeaders *hdrs,
32 const char *name,
33 const char *value);
34SOUP_AVAILABLE_IN_2_4
35void soup_message_headers_replace (SoupMessageHeaders *hdrs,
36 const char *name,
37 const char *value);
38
39SOUP_AVAILABLE_IN_2_4
40void soup_message_headers_remove (SoupMessageHeaders *hdrs,
41 const char *name);
42SOUP_AVAILABLE_IN_2_4
43void soup_message_headers_clear (SoupMessageHeaders *hdrs);
44
45SOUP_AVAILABLE_IN_2_36
46void soup_message_headers_clean_connection_headers (SoupMessageHeaders *hdrs);
47
48#ifndef SOUP_DISABLE_DEPRECATED
49SOUP_AVAILABLE_IN_2_4
50SOUP_DEPRECATED_IN_2_28_FOR ("soup_message_headers_get_one or soup_message_headers_get_list")
51const char *soup_message_headers_get (SoupMessageHeaders *hdrs,
52 const char *name);
53#endif
54SOUP_AVAILABLE_IN_2_28
55const char *soup_message_headers_get_one (SoupMessageHeaders *hdrs,
56 const char *name);
57SOUP_AVAILABLE_IN_2_28
58const char *soup_message_headers_get_list (SoupMessageHeaders *hdrs,
59 const char *name);
60SOUP_AVAILABLE_IN_2_50
61gboolean soup_message_headers_header_contains (SoupMessageHeaders *hdrs,
62 const char *name,
63 const char *token);
64SOUP_AVAILABLE_IN_2_50
65gboolean soup_message_headers_header_equals (SoupMessageHeaders *hdrs,
66 const char *name,
67 const char *value);
68
69typedef void (*SoupMessageHeadersForeachFunc)(const char *name,
70 const char *value,
71 gpointer user_data);
72
73SOUP_AVAILABLE_IN_2_4
74void soup_message_headers_foreach (SoupMessageHeaders *hdrs,
75 SoupMessageHeadersForeachFunc func,
76 gpointer user_data);
77
78SOUP_AVAILABLE_IN_2_50
79SoupMessageHeadersType soup_message_headers_get_headers_type (SoupMessageHeaders *hdrs);
80
81typedef struct {
82 /*< private >*/
83 gpointer dummy[3];
84} SoupMessageHeadersIter;
85
86SOUP_AVAILABLE_IN_2_4
87void soup_message_headers_iter_init (SoupMessageHeadersIter *iter,
88 SoupMessageHeaders *hdrs);
89SOUP_AVAILABLE_IN_2_4
90gboolean soup_message_headers_iter_next (SoupMessageHeadersIter *iter,
91 const char **name,
92 const char **value);
93
94/* Specific headers */
95
96typedef enum {
97 SOUP_ENCODING_UNRECOGNIZED,
98 SOUP_ENCODING_NONE,
99 SOUP_ENCODING_CONTENT_LENGTH,
100 SOUP_ENCODING_EOF,
101 SOUP_ENCODING_CHUNKED,
102 SOUP_ENCODING_BYTERANGES
103} SoupEncoding;
104
105SOUP_AVAILABLE_IN_2_4
106SoupEncoding soup_message_headers_get_encoding (SoupMessageHeaders *hdrs);
107SOUP_AVAILABLE_IN_2_4
108void soup_message_headers_set_encoding (SoupMessageHeaders *hdrs,
109 SoupEncoding encoding);
110
111SOUP_AVAILABLE_IN_2_4
112goffset soup_message_headers_get_content_length (SoupMessageHeaders *hdrs);
113SOUP_AVAILABLE_IN_2_4
114void soup_message_headers_set_content_length (SoupMessageHeaders *hdrs,
115 goffset content_length);
116
117typedef enum {
118 SOUP_EXPECTATION_UNRECOGNIZED = (1 << 0),
119 SOUP_EXPECTATION_CONTINUE = (1 << 1)
120} SoupExpectation;
121
122SOUP_AVAILABLE_IN_2_4
123SoupExpectation soup_message_headers_get_expectations (SoupMessageHeaders *hdrs);
124SOUP_AVAILABLE_IN_2_4
125void soup_message_headers_set_expectations (SoupMessageHeaders *hdrs,
126 SoupExpectation expectations);
127
128typedef struct {
129 goffset start;
130 goffset end;
131} SoupRange;
132
133SOUP_AVAILABLE_IN_2_26
134gboolean soup_message_headers_get_ranges (SoupMessageHeaders *hdrs,
135 goffset total_length,
136 SoupRange **ranges,
137 int *length);
138SOUP_AVAILABLE_IN_2_26
139void soup_message_headers_free_ranges (SoupMessageHeaders *hdrs,
140 SoupRange *ranges);
141SOUP_AVAILABLE_IN_2_26
142void soup_message_headers_set_ranges (SoupMessageHeaders *hdrs,
143 SoupRange *ranges,
144 int length);
145SOUP_AVAILABLE_IN_2_26
146void soup_message_headers_set_range (SoupMessageHeaders *hdrs,
147 goffset start,
148 goffset end);
149
150SOUP_AVAILABLE_IN_2_26
151gboolean soup_message_headers_get_content_range (SoupMessageHeaders *hdrs,
152 goffset *start,
153 goffset *end,
154 goffset *total_length);
155SOUP_AVAILABLE_IN_2_26
156void soup_message_headers_set_content_range (SoupMessageHeaders *hdrs,
157 goffset start,
158 goffset end,
159 goffset total_length);
160
161
162SOUP_AVAILABLE_IN_2_26
163const char *soup_message_headers_get_content_type (SoupMessageHeaders *hdrs,
164 GHashTable **params);
165SOUP_AVAILABLE_IN_2_26
166void soup_message_headers_set_content_type (SoupMessageHeaders *hdrs,
167 const char *content_type,
168 GHashTable *params);
169
170SOUP_AVAILABLE_IN_2_26
171gboolean soup_message_headers_get_content_disposition (SoupMessageHeaders *hdrs,
172 char **disposition,
173 GHashTable **params);
174SOUP_AVAILABLE_IN_2_26
175void soup_message_headers_set_content_disposition (SoupMessageHeaders *hdrs,
176 const char *disposition,
177 GHashTable *params);
178
179G_END_DECLS
180
181#endif /* __SOUP_MESSAGE_HEADERS_H__ */
182