summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2003-09-03 14:00:24 +0000
committerDan Winship <danw@src.gnome.org>2003-09-03 14:00:24 +0000
commit3352b0ee56a2e1e84bc20def9ae16a648ef4f51f (patch)
tree1bd38d29e15a9ae1ce8aa78c019f9d18197667cf /tests
parent1cc11d717a29e5835d03eb244f3a05e8bd6c039c (diff)
downloadlibsoup-3352b0ee56a2e1e84bc20def9ae16a648ef4f51f.tar.gz
libsoup-3352b0ee56a2e1e84bc20def9ae16a648ef4f51f.tar.bz2
libsoup-3352b0ee56a2e1e84bc20def9ae16a648ef4f51f.zip
Renamed from soup-error.h, with types and defines renamed accordingly.
* libsoup/soup-status.h: Renamed from soup-error.h, with types and defines renamed accordingly. * libsoup/soup-message.h (SoupMessage): Rename errorcode to status_code and errorphrase to reason_phrase. Remove errorclass. (SOUP_MESSAGE_IS_ERROR): Remove this. You can't classify redirects as being either "errors" or "not errors", so its semantics are guaranteed to be wrong sometimes. * libsoup/soup-message.c (soup_message_set_status, soup_message_set_status_full): Renamed * libsoup/soup-message-handlers.c (soup_message_add_status_code_handler, soup_message_add_status_class_handler): Rename. * libsoup/soup-session.c (soup_session_send_message): Make this return a status code rather than a status class. * libsoup/soup-message-private.h (SoupMessagePrivate): Remove some unrelated unused fields (retries, callback, user_data). * ...: Updates
Diffstat (limited to 'tests')
-rw-r--r--tests/auth-test.c20
-rw-r--r--tests/get.c6
-rw-r--r--tests/simple-httpd.c18
-rw-r--r--tests/simple-proxy.c7
4 files changed, 26 insertions, 25 deletions
diff --git a/tests/auth-test.c b/tests/auth-test.c
index b0562275..8fe73b54 100644
--- a/tests/auth-test.c
+++ b/tests/auth-test.c
@@ -198,7 +198,7 @@ handler (SoupMessage *msg, gpointer data)
auth = identify_auth (msg);
- printf (" %d %s (using %s)\n", msg->errorcode, msg->errorphrase,
+ printf (" %d %s (using %s)\n", msg->status_code, msg->reason_phrase,
auths[auth]);
if (*expected) {
@@ -237,17 +237,17 @@ main (int argc, char **argv)
}
expected = g_strdup (tests[i].expected);
- soup_message_add_error_code_handler (
- msg, SOUP_ERROR_UNAUTHORIZED,
+ soup_message_add_status_code_handler (
+ msg, SOUP_STATUS_UNAUTHORIZED,
SOUP_HANDLER_PRE_BODY, handler, expected);
- soup_message_add_error_code_handler (
- msg, SOUP_ERROR_OK, SOUP_HANDLER_PRE_BODY,
+ soup_message_add_status_code_handler (
+ msg, SOUP_STATUS_OK, SOUP_HANDLER_PRE_BODY,
handler, expected);
soup_session_send_message (session, msg);
- if (msg->errorcode != SOUP_ERROR_UNAUTHORIZED &&
- msg->errorcode != SOUP_ERROR_OK) {
- printf (" %d %s !\n", msg->errorcode,
- msg->errorphrase);
+ if (msg->status_code != SOUP_STATUS_UNAUTHORIZED &&
+ msg->status_code != SOUP_STATUS_OK) {
+ printf (" %d %s !\n", msg->status_code,
+ msg->reason_phrase);
}
if (*expected) {
printf (" expected %d more round(s)\n",
@@ -256,7 +256,7 @@ main (int argc, char **argv)
}
g_free (expected);
- if (SOUP_ERROR_IS_SUCCESSFUL (msg->errorcode) !=
+ if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code) !=
tests[i].success) {
printf (" expected %s\n",
tests[i].success ? "success" : "failure");
diff --git a/tests/get.c b/tests/get.c
index 90ddb6f3..efb9b9d5 100644
--- a/tests/get.c
+++ b/tests/get.c
@@ -107,13 +107,13 @@ got_url (SoupMessage *msg, gpointer uri)
fprintf (stderr, " Error: not under %s\n", base_uri->path);
goto DONE;
}
- printf ("%s: %d %s\n", name, msg->errorcode, msg->errorphrase);
+ printf ("%s: %d %s\n", name, msg->status_code, msg->reason_phrase);
name += strlen (base_uri->path);
if (*name == '/')
name++;
- if (SOUP_ERROR_IS_REDIRECTION (msg->errorcode)) {
+ if (SOUP_STATUS_IS_REDIRECTION (msg->status_code)) {
unlink (name);
header = soup_message_get_header (msg->response_headers, "Location");
if (header) {
@@ -123,7 +123,7 @@ got_url (SoupMessage *msg, gpointer uri)
goto DONE;
}
- if (!SOUP_ERROR_IS_SUCCESSFUL (msg->errorcode))
+ if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
goto DONE;
if (recurse)
diff --git a/tests/simple-httpd.c b/tests/simple-httpd.c
index e34f0132..74bcb786 100644
--- a/tests/simple-httpd.c
+++ b/tests/simple-httpd.c
@@ -40,13 +40,13 @@ server_callback (SoupServerContext *context, SoupMessage *msg, gpointer data)
printf ("%.*s\n", msg->request.length, msg->request.body);
if (soup_method_get_id (msg->method) != SOUP_METHOD_ID_GET) {
- soup_message_set_error (msg, SOUP_ERROR_NOT_IMPLEMENTED);
+ soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
goto DONE;
}
if (path) {
if (*path != '/') {
- soup_message_set_error (msg, SOUP_ERROR_BAD_REQUEST);
+ soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
goto DONE;
}
} else
@@ -58,11 +58,11 @@ server_callback (SoupServerContext *context, SoupMessage *msg, gpointer data)
if (stat (path_to_open, &st) == -1) {
g_free (path_to_open);
if (errno == EPERM)
- soup_message_set_error (msg, SOUP_ERROR_FORBIDDEN);
+ soup_message_set_status (msg, SOUP_STATUS_FORBIDDEN);
else if (errno == ENOENT)
- soup_message_set_error (msg, SOUP_ERROR_NOT_FOUND);
+ soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND);
else
- soup_message_set_error (msg, SOUP_ERROR_INTERNAL);
+ soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
goto DONE;
}
@@ -75,7 +75,7 @@ server_callback (SoupServerContext *context, SoupMessage *msg, gpointer data)
redir_uri = g_strdup_printf ("%s/", uri);
soup_message_add_header (msg->response_headers,
"Location", redir_uri);
- soup_message_set_error (msg, SOUP_ERROR_MOVED_PERMANENTLY);
+ soup_message_set_status (msg, SOUP_STATUS_MOVED_PERMANENTLY);
g_free (redir_uri);
g_free (uri);
g_free (path_to_open);
@@ -90,7 +90,7 @@ server_callback (SoupServerContext *context, SoupMessage *msg, gpointer data)
fd = open (path_to_open, O_RDONLY);
g_free (path_to_open);
if (fd == -1) {
- soup_message_set_error (msg, SOUP_ERROR_INTERNAL);
+ soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
goto DONE;
}
@@ -101,13 +101,13 @@ server_callback (SoupServerContext *context, SoupMessage *msg, gpointer data)
read (fd, msg->response.body, msg->response.length);
close (fd);
- soup_message_set_error (msg, SOUP_ERROR_OK);
+ soup_message_set_status (msg, SOUP_STATUS_OK);
DONE:
g_free (path);
soup_server_message_set_encoding (SOUP_SERVER_MESSAGE (msg),
SOUP_TRANSFER_CONTENT_LENGTH);
- printf (" -> %d %s\n\n", msg->errorcode, msg->errorphrase);
+ printf (" -> %d %s\n\n", msg->status_code, msg->reason_phrase);
}
static void
diff --git a/tests/simple-proxy.c b/tests/simple-proxy.c
index f0926a0a..3af0a75d 100644
--- a/tests/simple-proxy.c
+++ b/tests/simple-proxy.c
@@ -37,9 +37,10 @@ send_headers (SoupMessage *from, SoupMessage *to)
{
printf ("[%p] HTTP/1.%d %d %s\n", to,
soup_message_get_http_version (from),
- from->errorcode, from->errorphrase);
+ from->status_code, from->reason_phrase);
- soup_message_set_error_full (to, from->errorcode, from->errorphrase);
+ soup_message_set_status_full (to, from->status_code,
+ from->reason_phrase);
soup_message_foreach_header (from->response_headers, copy_header,
to->response_headers);
soup_message_remove_header (to->response_headers, "Content-Length");
@@ -84,7 +85,7 @@ server_callback (SoupServerContext *context, SoupMessage *msg, gpointer data)
soup_message_get_http_version (msg));
if (soup_method_get_id (msg->method) == SOUP_METHOD_ID_CONNECT) {
- soup_message_set_error (msg, SOUP_ERROR_NOT_IMPLEMENTED);
+ soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
return;
}