• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * soup-status.h: HTTP status code and status class definitions
4  *
5  * Copyright (C) 2001-2003, Ximian, Inc.
6  */
7 
8 #ifndef __SOUP_STATUS_H__
9 #define __SOUP_STATUS_H__ 1
10 
11 #include <libsoup/soup-version.h>
12 
13 G_BEGIN_DECLS
14 
15 #define SOUP_STATUS_IS_TRANSPORT_ERROR(status) ((status) >  0   && (status) < 100)
16 #define SOUP_STATUS_IS_INFORMATIONAL(status)   ((status) >= 100 && (status) < 200)
17 #define SOUP_STATUS_IS_SUCCESSFUL(status)      ((status) >= 200 && (status) < 300)
18 #define SOUP_STATUS_IS_REDIRECTION(status)     ((status) >= 300 && (status) < 400)
19 #define SOUP_STATUS_IS_CLIENT_ERROR(status)    ((status) >= 400 && (status) < 500)
20 #define SOUP_STATUS_IS_SERVER_ERROR(status)    ((status) >= 500 && (status) < 600)
21 
22 typedef enum {
23 	SOUP_STATUS_NONE,
24 
25 	/* Transport Errors */
26 	SOUP_STATUS_CANCELLED                       = 1,
27 	SOUP_STATUS_CANT_RESOLVE,
28 	SOUP_STATUS_CANT_RESOLVE_PROXY,
29 	SOUP_STATUS_CANT_CONNECT,
30 	SOUP_STATUS_CANT_CONNECT_PROXY,
31 	SOUP_STATUS_SSL_FAILED,
32 	SOUP_STATUS_IO_ERROR,
33 	SOUP_STATUS_MALFORMED,
34 	SOUP_STATUS_TRY_AGAIN,
35 	SOUP_STATUS_TOO_MANY_REDIRECTS,
36 	SOUP_STATUS_TLS_FAILED,
37 
38 	/* HTTP Status Codes */
39 	SOUP_STATUS_CONTINUE                        = 100,
40 	SOUP_STATUS_SWITCHING_PROTOCOLS             = 101,
41 	SOUP_STATUS_PROCESSING                      = 102, /* WebDAV */
42 
43 	SOUP_STATUS_OK                              = 200,
44 	SOUP_STATUS_CREATED                         = 201,
45 	SOUP_STATUS_ACCEPTED                        = 202,
46 	SOUP_STATUS_NON_AUTHORITATIVE               = 203,
47 	SOUP_STATUS_NO_CONTENT                      = 204,
48 	SOUP_STATUS_RESET_CONTENT                   = 205,
49 	SOUP_STATUS_PARTIAL_CONTENT                 = 206,
50 	SOUP_STATUS_MULTI_STATUS                    = 207, /* WebDAV */
51 
52 	SOUP_STATUS_MULTIPLE_CHOICES                = 300,
53 	SOUP_STATUS_MOVED_PERMANENTLY               = 301,
54 	SOUP_STATUS_FOUND                           = 302,
55 	SOUP_STATUS_MOVED_TEMPORARILY               = 302, /* RFC 2068 */
56 	SOUP_STATUS_SEE_OTHER                       = 303,
57 	SOUP_STATUS_NOT_MODIFIED                    = 304,
58 	SOUP_STATUS_USE_PROXY                       = 305,
59 	SOUP_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL  = 306, /* (reserved) */
60 	SOUP_STATUS_TEMPORARY_REDIRECT              = 307,
61 
62 	SOUP_STATUS_BAD_REQUEST                     = 400,
63 	SOUP_STATUS_UNAUTHORIZED                    = 401,
64 	SOUP_STATUS_PAYMENT_REQUIRED                = 402, /* (reserved) */
65 	SOUP_STATUS_FORBIDDEN                       = 403,
66 	SOUP_STATUS_NOT_FOUND                       = 404,
67 	SOUP_STATUS_METHOD_NOT_ALLOWED              = 405,
68 	SOUP_STATUS_NOT_ACCEPTABLE                  = 406,
69 	SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED   = 407,
70 	SOUP_STATUS_PROXY_UNAUTHORIZED              = SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED,
71 	SOUP_STATUS_REQUEST_TIMEOUT                 = 408,
72 	SOUP_STATUS_CONFLICT                        = 409,
73 	SOUP_STATUS_GONE                            = 410,
74 	SOUP_STATUS_LENGTH_REQUIRED                 = 411,
75 	SOUP_STATUS_PRECONDITION_FAILED             = 412,
76 	SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE        = 413,
77 	SOUP_STATUS_REQUEST_URI_TOO_LONG            = 414,
78 	SOUP_STATUS_UNSUPPORTED_MEDIA_TYPE          = 415,
79 	SOUP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
80 	SOUP_STATUS_INVALID_RANGE                   = SOUP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE,
81 	SOUP_STATUS_EXPECTATION_FAILED              = 417,
82 	SOUP_STATUS_UNPROCESSABLE_ENTITY            = 422, /* WebDAV */
83 	SOUP_STATUS_LOCKED                          = 423, /* WebDAV */
84 	SOUP_STATUS_FAILED_DEPENDENCY               = 424, /* WebDAV */
85 
86 	SOUP_STATUS_INTERNAL_SERVER_ERROR           = 500,
87 	SOUP_STATUS_NOT_IMPLEMENTED                 = 501,
88 	SOUP_STATUS_BAD_GATEWAY                     = 502,
89 	SOUP_STATUS_SERVICE_UNAVAILABLE             = 503,
90 	SOUP_STATUS_GATEWAY_TIMEOUT                 = 504,
91 	SOUP_STATUS_HTTP_VERSION_NOT_SUPPORTED      = 505,
92 	SOUP_STATUS_INSUFFICIENT_STORAGE            = 507, /* WebDAV search */
93 	SOUP_STATUS_NOT_EXTENDED                    = 510  /* RFC 2774 */
94 } SoupStatus;
95 
96 SOUP_AVAILABLE_IN_2_4
97 const char *soup_status_get_phrase (guint status_code);
98 SOUP_AVAILABLE_IN_2_26
99 guint       soup_status_proxify    (guint status_code);
100 
101 /**
102  * SOUP_HTTP_ERROR:
103  *
104  * A #GError domain representing an HTTP status. Use a #SoupStatus for
105  * the <structfield>code</structfield> value.
106  **/
107 #define SOUP_HTTP_ERROR (soup_http_error_quark())
108 SOUP_AVAILABLE_IN_2_4
109 GQuark soup_http_error_quark (void);
110 
111 #ifndef SOUP_DISABLE_DEPRECATED
112 /* For introspection purposes, we create a duplicate enum type under
113  * the deprecated type name, since some (all?) bindings don't handle
114  * enum type typedefs the way we want.
115  */
116 typedef enum {
117 	SOUP_KNOWN_STATUS_CODE_NONE,
118 
119 	SOUP_KNOWN_STATUS_CODE_CANCELLED                       = 1,
120 	SOUP_KNOWN_STATUS_CODE_CANT_RESOLVE,
121 	SOUP_KNOWN_STATUS_CODE_CANT_RESOLVE_PROXY,
122 	SOUP_KNOWN_STATUS_CODE_CANT_CONNECT,
123 	SOUP_KNOWN_STATUS_CODE_CANT_CONNECT_PROXY,
124 	SOUP_KNOWN_STATUS_CODE_SSL_FAILED,
125 	SOUP_KNOWN_STATUS_CODE_IO_ERROR,
126 	SOUP_KNOWN_STATUS_CODE_MALFORMED,
127 	SOUP_KNOWN_STATUS_CODE_TRY_AGAIN,
128 	SOUP_KNOWN_STATUS_CODE_TOO_MANY_REDIRECTS,
129 	SOUP_KNOWN_STATUS_CODE_TLS_FAILED,
130 
131 	SOUP_KNOWN_STATUS_CODE_CONTINUE                        = 100,
132 	SOUP_KNOWN_STATUS_CODE_SWITCHING_PROTOCOLS             = 101,
133 	SOUP_KNOWN_STATUS_CODE_PROCESSING                      = 102,
134 
135 	SOUP_KNOWN_STATUS_CODE_OK                              = 200,
136 	SOUP_KNOWN_STATUS_CODE_CREATED                         = 201,
137 	SOUP_KNOWN_STATUS_CODE_ACCEPTED                        = 202,
138 	SOUP_KNOWN_STATUS_CODE_NON_AUTHORITATIVE               = 203,
139 	SOUP_KNOWN_STATUS_CODE_NO_CONTENT                      = 204,
140 	SOUP_KNOWN_STATUS_CODE_RESET_CONTENT                   = 205,
141 	SOUP_KNOWN_STATUS_CODE_PARTIAL_CONTENT                 = 206,
142 	SOUP_KNOWN_STATUS_CODE_MULTI_STATUS                    = 207,
143 
144 	SOUP_KNOWN_STATUS_CODE_MULTIPLE_CHOICES                = 300,
145 	SOUP_KNOWN_STATUS_CODE_MOVED_PERMANENTLY               = 301,
146 	SOUP_KNOWN_STATUS_CODE_FOUND                           = 302,
147 	SOUP_KNOWN_STATUS_CODE_MOVED_TEMPORARILY               = 302,
148 	SOUP_KNOWN_STATUS_CODE_SEE_OTHER                       = 303,
149 	SOUP_KNOWN_STATUS_CODE_NOT_MODIFIED                    = 304,
150 	SOUP_KNOWN_STATUS_CODE_USE_PROXY                       = 305,
151 	SOUP_KNOWN_STATUS_CODE_NOT_APPEARING_IN_THIS_PROTOCOL  = 306,
152 	SOUP_KNOWN_STATUS_CODE_TEMPORARY_REDIRECT              = 307,
153 
154 	SOUP_KNOWN_STATUS_CODE_BAD_REQUEST                     = 400,
155 	SOUP_KNOWN_STATUS_CODE_UNAUTHORIZED                    = 401,
156 	SOUP_KNOWN_STATUS_CODE_PAYMENT_REQUIRED                = 402,
157 	SOUP_KNOWN_STATUS_CODE_FORBIDDEN                       = 403,
158 	SOUP_KNOWN_STATUS_CODE_NOT_FOUND                       = 404,
159 	SOUP_KNOWN_STATUS_CODE_METHOD_NOT_ALLOWED              = 405,
160 	SOUP_KNOWN_STATUS_CODE_NOT_ACCEPTABLE                  = 406,
161 	SOUP_KNOWN_STATUS_CODE_PROXY_AUTHENTICATION_REQUIRED   = 407,
162 	SOUP_KNOWN_STATUS_CODE_PROXY_UNAUTHORIZED              = SOUP_KNOWN_STATUS_CODE_PROXY_AUTHENTICATION_REQUIRED,
163 	SOUP_KNOWN_STATUS_CODE_REQUEST_TIMEOUT                 = 408,
164 	SOUP_KNOWN_STATUS_CODE_CONFLICT                        = 409,
165 	SOUP_KNOWN_STATUS_CODE_GONE                            = 410,
166 	SOUP_KNOWN_STATUS_CODE_LENGTH_REQUIRED                 = 411,
167 	SOUP_KNOWN_STATUS_CODE_PRECONDITION_FAILED             = 412,
168 	SOUP_KNOWN_STATUS_CODE_REQUEST_ENTITY_TOO_LARGE        = 413,
169 	SOUP_KNOWN_STATUS_CODE_REQUEST_URI_TOO_LONG            = 414,
170 	SOUP_KNOWN_STATUS_CODE_UNSUPPORTED_MEDIA_TYPE          = 415,
171 	SOUP_KNOWN_STATUS_CODE_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
172 	SOUP_KNOWN_STATUS_CODE_INVALID_RANGE                   = SOUP_KNOWN_STATUS_CODE_REQUESTED_RANGE_NOT_SATISFIABLE,
173 	SOUP_KNOWN_STATUS_CODE_EXPECTATION_FAILED              = 417,
174 	SOUP_KNOWN_STATUS_CODE_UNPROCESSABLE_ENTITY            = 422,
175 	SOUP_KNOWN_STATUS_CODE_LOCKED                          = 423,
176 	SOUP_KNOWN_STATUS_CODE_FAILED_DEPENDENCY               = 424,
177 
178 	SOUP_KNOWN_STATUS_CODE_INTERNAL_SERVER_ERROR           = 500,
179 	SOUP_KNOWN_STATUS_CODE_NOT_IMPLEMENTED                 = 501,
180 	SOUP_KNOWN_STATUS_CODE_BAD_GATEWAY                     = 502,
181 	SOUP_KNOWN_STATUS_CODE_SERVICE_UNAVAILABLE             = 503,
182 	SOUP_KNOWN_STATUS_CODE_GATEWAY_TIMEOUT                 = 504,
183 	SOUP_KNOWN_STATUS_CODE_HTTP_VERSION_NOT_SUPPORTED      = 505,
184 	SOUP_KNOWN_STATUS_CODE_INSUFFICIENT_STORAGE            = 507,
185 	SOUP_KNOWN_STATUS_CODE_NOT_EXTENDED                    = 510
186 } SoupKnownStatusCode;
187 #endif
188 
189 G_END_DECLS
190 
191 #endif /* __SOUP_STATUS_H__ */
192