1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright 2007, 2008 Red Hat, Inc.
4 */
5
6#ifndef __SOUP_COOKIE_H__
7#define __SOUP_COOKIE_H__ 1
8
9#include <libsoup/soup-types.h>
10
11G_BEGIN_DECLS
12
13struct _SoupCookie {
14 char *name;
15 char *value;
16 char *domain;
17 char *path;
18 SoupDate *expires;
19 gboolean secure;
20 gboolean http_only;
21};
22
23SOUP_AVAILABLE_IN_2_24
24GType soup_cookie_get_type (void);
25#define SOUP_TYPE_COOKIE (soup_cookie_get_type())
26
27#define SOUP_COOKIE_MAX_AGE_ONE_HOUR (60 * 60)
28#define SOUP_COOKIE_MAX_AGE_ONE_DAY (SOUP_COOKIE_MAX_AGE_ONE_HOUR * 24)
29#define SOUP_COOKIE_MAX_AGE_ONE_WEEK (SOUP_COOKIE_MAX_AGE_ONE_DAY * 7)
30#define SOUP_COOKIE_MAX_AGE_ONE_YEAR (SOUP_COOKIE_MAX_AGE_ONE_DAY * 365.2422)
31
32SOUP_AVAILABLE_IN_2_24
33SoupCookie *soup_cookie_new (const char *name,
34 const char *value,
35 const char *domain,
36 const char *path,
37 int max_age);
38SOUP_AVAILABLE_IN_2_24
39SoupCookie *soup_cookie_parse (const char *header,
40 SoupURI *origin);
41SOUP_AVAILABLE_IN_2_24
42SoupCookie *soup_cookie_copy (SoupCookie *cookie);
43
44SOUP_AVAILABLE_IN_2_32
45const char *soup_cookie_get_name (SoupCookie *cookie);
46SOUP_AVAILABLE_IN_2_24
47void soup_cookie_set_name (SoupCookie *cookie,
48 const char *name);
49SOUP_AVAILABLE_IN_2_32
50const char *soup_cookie_get_value (SoupCookie *cookie);
51SOUP_AVAILABLE_IN_2_24
52void soup_cookie_set_value (SoupCookie *cookie,
53 const char *value);
54SOUP_AVAILABLE_IN_2_32
55const char *soup_cookie_get_domain (SoupCookie *cookie);
56SOUP_AVAILABLE_IN_2_24
57void soup_cookie_set_domain (SoupCookie *cookie,
58 const char *domain);
59SOUP_AVAILABLE_IN_2_32
60const char *soup_cookie_get_path (SoupCookie *cookie);
61SOUP_AVAILABLE_IN_2_24
62void soup_cookie_set_path (SoupCookie *cookie,
63 const char *path);
64SOUP_AVAILABLE_IN_2_24
65void soup_cookie_set_max_age (SoupCookie *cookie,
66 int max_age);
67SOUP_AVAILABLE_IN_2_32
68SoupDate *soup_cookie_get_expires (SoupCookie *cookie);
69SOUP_AVAILABLE_IN_2_24
70void soup_cookie_set_expires (SoupCookie *cookie,
71 SoupDate *expires);
72SOUP_AVAILABLE_IN_2_32
73gboolean soup_cookie_get_secure (SoupCookie *cookie);
74SOUP_AVAILABLE_IN_2_24
75void soup_cookie_set_secure (SoupCookie *cookie,
76 gboolean secure);
77SOUP_AVAILABLE_IN_2_32
78gboolean soup_cookie_get_http_only (SoupCookie *cookie);
79SOUP_AVAILABLE_IN_2_24
80void soup_cookie_set_http_only (SoupCookie *cookie,
81 gboolean http_only);
82
83SOUP_AVAILABLE_IN_2_24
84char *soup_cookie_to_set_cookie_header (SoupCookie *cookie);
85SOUP_AVAILABLE_IN_2_24
86char *soup_cookie_to_cookie_header (SoupCookie *cookie);
87
88SOUP_AVAILABLE_IN_2_24
89gboolean soup_cookie_applies_to_uri (SoupCookie *cookie,
90 SoupURI *uri);
91SOUP_AVAILABLE_IN_2_24
92gboolean soup_cookie_equal (SoupCookie *cookie1,
93 SoupCookie *cookie2);
94
95SOUP_AVAILABLE_IN_2_24
96void soup_cookie_free (SoupCookie *cookie);
97
98SOUP_AVAILABLE_IN_2_24
99GSList *soup_cookies_from_response (SoupMessage *msg);
100SOUP_AVAILABLE_IN_2_24
101GSList *soup_cookies_from_request (SoupMessage *msg);
102
103SOUP_AVAILABLE_IN_2_24
104void soup_cookies_to_response (GSList *cookies,
105 SoupMessage *msg);
106SOUP_AVAILABLE_IN_2_24
107void soup_cookies_to_request (GSList *cookies,
108 SoupMessage *msg);
109
110SOUP_AVAILABLE_IN_2_24
111void soup_cookies_free (GSList *cookies);
112
113SOUP_AVAILABLE_IN_2_24
114char *soup_cookies_to_cookie_header (GSList *cookies);
115
116SOUP_AVAILABLE_IN_2_30
117gboolean soup_cookie_domain_matches (SoupCookie *cookie,
118 const char *host);
119
120G_END_DECLS
121
122#endif /* __SOUP_COOKIE_H__ */
123