source: trunk/third/libsoup/libsoup/soup-status.c @ 21108

Revision 21108, 4.4 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21107, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * soup-status.c: Status code descriptions
4 *
5 * Copyright (C) 2001-2003, Ximian, Inc.
6 */
7
8#include <glib.h>
9
10#include "soup-status.h"
11
12struct {
13        guint code;
14        const char *phrase;
15} reason_phrases [] = {
16        /* Transport errors */
17        { SOUP_STATUS_CANCELLED,                  "Cancelled" },
18        { SOUP_STATUS_CANT_RESOLVE,               "Cannot resolve hostname" },
19        { SOUP_STATUS_CANT_RESOLVE_PROXY,         "Cannot resolve proxy hostname" },
20        { SOUP_STATUS_CANT_CONNECT,               "Cannot connect to destination" },
21        { SOUP_STATUS_CANT_CONNECT_PROXY,         "Cannot connect to proxy" },
22        { SOUP_STATUS_SSL_FAILED,                 "SSL handshake failed" },
23        { SOUP_STATUS_IO_ERROR,                   "Connection terminated unexpectedly" },
24        { SOUP_STATUS_MALFORMED,                  "Message Corrupt" },
25        /* SOUP_STATUS_TRY_AGAIN should never be returned to the caller */
26
27        /* Informational */
28        { SOUP_STATUS_CONTINUE,                   "Continue" },
29        { SOUP_STATUS_SWITCHING_PROTOCOLS,        "Switching Protocols" },
30        { SOUP_STATUS_PROCESSING,                 "Processing" },
31
32        /* Success */
33        { SOUP_STATUS_OK,                         "OK" },
34        { SOUP_STATUS_CREATED,                    "Created" },
35        { SOUP_STATUS_ACCEPTED,                   "Accepted" },
36        { SOUP_STATUS_NON_AUTHORITATIVE,          "Non-Authoritative Information" },
37        { SOUP_STATUS_NO_CONTENT,                 "No Content" },
38        { SOUP_STATUS_RESET_CONTENT,              "Reset Content" },
39        { SOUP_STATUS_PARTIAL_CONTENT,            "Partial Content" },
40        { SOUP_STATUS_MULTI_STATUS,               "Multi-Status" },
41
42        /* Redirection */
43        { SOUP_STATUS_MULTIPLE_CHOICES,           "Multiple Choices" },
44        { SOUP_STATUS_MOVED_PERMANENTLY,          "Moved Permanently" },
45        { SOUP_STATUS_FOUND,                      "Found" },
46        { SOUP_STATUS_SEE_OTHER,                  "See Other" },
47        { SOUP_STATUS_NOT_MODIFIED,               "Not Modified" },
48        { SOUP_STATUS_USE_PROXY,                  "Use Proxy" },
49        { SOUP_STATUS_TEMPORARY_REDIRECT,         "Temporary Redirect" },
50
51        /* Client error */
52        { SOUP_STATUS_BAD_REQUEST,                "Bad Request" },
53        { SOUP_STATUS_UNAUTHORIZED,               "Unauthorized" },
54        { SOUP_STATUS_PAYMENT_REQUIRED,           "Payment Required" },
55        { SOUP_STATUS_FORBIDDEN,                  "Forbidden" },
56        { SOUP_STATUS_NOT_FOUND,                  "Not Found" },
57        { SOUP_STATUS_METHOD_NOT_ALLOWED,         "Method Not Allowed" },
58        { SOUP_STATUS_NOT_ACCEPTABLE,             "Not Acceptable" },
59        { SOUP_STATUS_PROXY_UNAUTHORIZED,         "Proxy Authentication Required" },
60        { SOUP_STATUS_REQUEST_TIMEOUT,            "Request Timeout" },
61        { SOUP_STATUS_CONFLICT,                   "Conflict" },
62        { SOUP_STATUS_GONE,                       "Gone" },
63        { SOUP_STATUS_LENGTH_REQUIRED,            "Length Required" },
64        { SOUP_STATUS_PRECONDITION_FAILED,        "Precondition Failed" },
65        { SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE,   "Request Entity Too Large" },
66        { SOUP_STATUS_REQUEST_URI_TOO_LONG,       "Request-URI Too Long" },
67        { SOUP_STATUS_UNSUPPORTED_MEDIA_TYPE,     "Unsupported Media Type" },
68        { SOUP_STATUS_INVALID_RANGE,              "Requested Range Not Satisfiable" },
69        { SOUP_STATUS_EXPECTATION_FAILED,         "Expectation Failed" },
70        { SOUP_STATUS_UNPROCESSABLE_ENTITY,       "Unprocessable Entity" },
71        { SOUP_STATUS_LOCKED,                     "Locked" },
72        { SOUP_STATUS_FAILED_DEPENDENCY,          "Failed Dependency" },
73
74        /* Server error */
75        { SOUP_STATUS_INTERNAL_SERVER_ERROR,      "Internal Server Error" },
76        { SOUP_STATUS_NOT_IMPLEMENTED,            "Not Implemented" },
77        { SOUP_STATUS_BAD_GATEWAY,                "Bad Gateway" },
78        { SOUP_STATUS_SERVICE_UNAVAILABLE,        "Service Unavailable" },
79        { SOUP_STATUS_GATEWAY_TIMEOUT,            "Gateway Timeout" },
80        { SOUP_STATUS_HTTP_VERSION_NOT_SUPPORTED, "HTTP Version Not Supported" },
81        { SOUP_STATUS_INSUFFICIENT_STORAGE,       "Insufficient Storage" },
82        { SOUP_STATUS_NOT_EXTENDED,               "Not Extended" },
83
84        { 0 }
85};
86
87/**
88 * soup_status_get_phrase:
89 * @status_code: an HTTP status code
90 *
91 * Looks up the stock HTTP description of @status_code.
92 *
93 * Return value: the (English) description of @status_code
94 **/
95const char *
96soup_status_get_phrase (guint status_code)
97{
98        int i;
99
100        for (i = 0; reason_phrases [i].code; i++) {
101                if (reason_phrases [i].code == status_code)
102                        return reason_phrases [i].phrase;
103        }
104
105        return "Unknown Error";
106}
Note: See TracBrowser for help on using the repository browser.