mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
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.
This commit is contained in:
parent
a97bcc68d7
commit
ece71b22c5
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user