[ostree] pull: Set an error when we get an unsuccessful HTTP response
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] pull: Set an error when we get an unsuccessful HTTP response
- Date: Wed, 22 Aug 2012 23:45:46 +0000 (UTC)
commit ece71b22c5b40587398709d89582e421dd1bad3c
Author: Colin Walters <walters verbum org>
Date: Wed Aug 22 19:40:45 2012 -0400
pull: Set an error when we get an unsuccessful HTTP response
Otherwise we'll e.g. try to parse 404 HTML as an object which will
fail.
src/ostree/ostree-fetcher.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/ostree/ostree-fetcher.c b/src/ostree/ostree-fetcher.c
index dcabf6e..3ef6e7e 100644
--- a/src/ostree/ostree-fetcher.c
+++ b/src/ostree/ostree-fetcher.c
@@ -187,15 +187,26 @@ on_request_sent (GObject *object,
{
OstreeFetcherPendingURI *pending = user_data;
GError *local_error = NULL;
+ ot_lobj SoupMessage *msg = NULL;
pending->request_body = soup_request_send_finish ((SoupRequest*) object,
result, &local_error);
+ msg = soup_request_http_get_message ((SoupRequestHTTP*) object);
+
if (!pending->request_body)
{
pending->state = OSTREE_FETCHER_STATE_COMPLETE;
g_simple_async_result_take_error (pending->result, local_error);
g_simple_async_result_complete (pending->result);
}
+ else if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
+ {
+ g_set_error (&local_error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Server returned status %u: %s",
+ msg->status_code, soup_status_get_phrase (msg->status_code));
+ g_simple_async_result_take_error (pending->result, local_error);
+ g_simple_async_result_complete (pending->result);
+ }
else
{
GOutputStreamSpliceFlags flags = G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]