2
* Copyright (C) 2012 Igalia S.L.
4
* Contact: Iago Toral Quiroga <itoral@igalia.com>
6
* Authors: Víctor M. Jáquez L. <vjaquez@igalia.com>
7
* Juan A. Suarez Romero <jasuarez@igalia.com>
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public License
11
* as published by the Free Software Foundation; version 2.1 of
12
* the License, or (at your option) any later version.
14
* This library is distributed in the hope that it will be useful, but
15
* WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
30
#include "grl-net-private.h"
33
parse_error (guint status,
35
const gchar *response,
36
GSimpleAsyncResult *result)
38
if (!response || *response == '\0')
42
case SOUP_STATUS_CANT_RESOLVE:
43
case SOUP_STATUS_CANT_CONNECT:
44
case SOUP_STATUS_SSL_FAILED:
45
case SOUP_STATUS_IO_ERROR:
46
g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
47
GRL_NET_WC_ERROR_NETWORK_ERROR,
48
"Cannot connect to the server");
50
case SOUP_STATUS_CANT_RESOLVE_PROXY:
51
case SOUP_STATUS_CANT_CONNECT_PROXY:
52
g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
53
GRL_NET_WC_ERROR_PROXY_ERROR,
54
"Cannot connect to the proxy server");
56
case SOUP_STATUS_INTERNAL_SERVER_ERROR: /* 500 */
57
case SOUP_STATUS_MALFORMED:
58
case SOUP_STATUS_BAD_REQUEST: /* 400 */
59
g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
60
GRL_NET_WC_ERROR_PROTOCOL_ERROR,
61
"Invalid request URI or header: %s",
64
case SOUP_STATUS_UNAUTHORIZED: /* 401 */
65
case SOUP_STATUS_FORBIDDEN: /* 403 */
66
g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
67
GRL_NET_WC_ERROR_AUTHENTICATION_REQUIRED,
68
"Authentication required: %s", response);
70
case SOUP_STATUS_NOT_FOUND: /* 404 */
71
g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
72
GRL_NET_WC_ERROR_NOT_FOUND,
73
"The requested resource was not found: %s",
76
case SOUP_STATUS_CONFLICT: /* 409 */
77
case SOUP_STATUS_PRECONDITION_FAILED: /* 412 */
78
g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
79
GRL_NET_WC_ERROR_CONFLICT,
80
"The entry has been modified since it was downloaded: %s",
83
case SOUP_STATUS_CANCELLED:
84
g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
85
GRL_NET_WC_ERROR_CANCELLED,
86
"Operation was cancelled");
89
g_message ("Unhandled status: %s", soup_status_get_phrase (status));