}
static int pakfire_client_auth_response(struct pakfire_xfer* xfer,
- pakfire_xfer_error_code_t code, json_object* response, void* data);
+ pakfire_xfer_error_code_t code, int status, json_object* response, void* data);
static int pakfire_client_auth_required(struct pakfire_client* self);
}
static int pakfire_client_auth_response(struct pakfire_xfer* xfer,
- pakfire_xfer_error_code_t code, json_object* response, void* data) {
+ pakfire_xfer_error_code_t code, int status, json_object* response, void* data) {
struct pakfire_client* client = data;
switch (code) {
}
static int pakfire_client_build_response(struct pakfire_xfer* xfer,
- pakfire_xfer_error_code_t status, struct json_object* response, void* data) {
+ pakfire_xfer_error_code_t code, int status, struct json_object* response, void* data) {
struct pakfire_client_build* build = data;
const char* uuid = NULL;
int r = 0;
goto ERROR;
// Call the callback
- r = build->callback(build->client, status, uuid, build->data);
+ r = build->callback(build->client, code, uuid, build->data);
}
ERROR:
}
static int pakfire_upload_payload_callback(struct pakfire_xfer* xfer,
- pakfire_xfer_error_code_t code, struct json_object* response, void* data) {
- pakfire_client_upload_status status = PAKFIRE_CLIENT_UPLOAD_SUCCESSFUL;
+ pakfire_xfer_error_code_t code, int status, struct json_object* response, void* data) {
+ pakfire_client_upload_status s = PAKFIRE_CLIENT_UPLOAD_SUCCESSFUL;
struct pakfire_client_upload* upload = data;
int r = 0;
break;
default:
- status = PAKFIRE_CLIENT_UPLOAD_ERROR;
+ s = PAKFIRE_CLIENT_UPLOAD_ERROR;
break;
}
// Call the callback (if any)
if (upload->callback)
- r = upload->callback(upload->client, status, upload->path, upload->uuid, upload->data);
+ r = upload->callback(upload->client, s, upload->path, upload->uuid, upload->data);
// Free the upload
pakfire_client_upload_free(upload);
}
static int pakfire_client_upload_response(struct pakfire_xfer* xfer,
- pakfire_xfer_error_code_t code, struct json_object* response, void* data) {
+ pakfire_xfer_error_code_t code, int status, struct json_object* response, void* data) {
struct pakfire_client_upload* self = data;
const char* uuid = NULL;
int r;
return r;
}
-static int pakfire_xfer_call_response_callback(struct pakfire_xfer* self, pakfire_xfer_error_code_t code) {
+static int pakfire_xfer_call_response_callback(struct pakfire_xfer* self, pakfire_xfer_error_code_t code, int status) {
struct json_object* response = NULL;
char* error = NULL;
int r;
}
// Run the callback
- r = self->callbacks.response(self, code, response, self->callbacks.data);
+ r = self->callbacks.response(self, code, status, response, self->callbacks.data);
ERROR:
if (response)
return r;
}
-static int pakfire_xfer_fail(struct pakfire_xfer* xfer, int code) {
+static int pakfire_xfer_fail(struct pakfire_xfer* xfer, pakfire_xfer_error_code_t code, int status) {
int r;
// Drop the hasher
// Call the response callback
if (xfer->callbacks.response) {
- r = pakfire_xfer_call_response_callback(xfer, code);
+ r = pakfire_xfer_call_response_callback(xfer, code, status);
if (r < 0)
return r;
}
// We seem to have lost the connection
case CURLE_GOT_NOTHING:
- return pakfire_xfer_fail(xfer, PAKFIRE_XFER_TRANSPORT_ERROR);
+ return pakfire_xfer_fail(xfer, PAKFIRE_XFER_TRANSPORT_ERROR, 599);
default:
ERROR(xfer->ctx, "Could not read from WebSocket: %s\n", curl_easy_strerror(r));
pakfire_hashes_dump(self->ctx, &computed_hashes, LOG_ERR);
// Consider the download failed
- return pakfire_xfer_fail(self, PAKFIRE_XFER_DIGEST_MISMATCH);
+ return pakfire_xfer_fail(self, PAKFIRE_XFER_DIGEST_MISMATCH, 599);
// Errors
default:
}
}
-static int pakfire_xfer_save(struct pakfire_xfer* xfer) {
+static int pakfire_xfer_save(struct pakfire_xfer* xfer, int status) {
int fd = -EBADF;
int r;
// Call the output callback if configured
if (xfer->callbacks.response)
- return pakfire_xfer_call_response_callback(xfer, PAKFIRE_XFER_OK);
+ return pakfire_xfer_call_response_callback(xfer, PAKFIRE_XFER_OK, status);
// Nothing to do if path isn't set
if (!*xfer->path)
CURL* h = xfer->handle;
int r;
const char* scheme = NULL;
- long response_code;
long http_version;
double total_time;
+ long status = 0;
curl_off_t download_size = 0;
curl_off_t download_speed = 0;
DEBUG(xfer->ctx, " Effective URL: %s\n", xfer->effective_url);
// Response code
- curl_easy_getinfo(h, CURLINFO_RESPONSE_CODE, &response_code);
- if (response_code)
- DEBUG(xfer->ctx, " Response code: %ld\n", response_code);
+ curl_easy_getinfo(h, CURLINFO_RESPONSE_CODE, &status);
+ if (status)
+ DEBUG(xfer->ctx, " Status Code: %ld\n", status);
// HTTP Version
curl_easy_getinfo(h, CURLINFO_HTTP_VERSION, &http_version);
return r;
// Save the payload
- r = pakfire_xfer_save(xfer);
+ r = pakfire_xfer_save(xfer, status);
if (r < 0)
return r;
break;
case PAKFIRE_XFER_UPLOAD:
// Call the output callback if configured
if (xfer->callbacks.response) {
- r = pakfire_xfer_call_response_callback(xfer, PAKFIRE_XFER_OK);
+ r = pakfire_xfer_call_response_callback(xfer, PAKFIRE_XFER_OK, status);
if (r < 0)
return r;
}
code = pakfire_xfer_code(code, code);
// Report that something went wrong
- r = pakfire_xfer_fail(xfer, code);
+ r = pakfire_xfer_fail(xfer, code, status);
if (r < 0)
return r;
}