Skip to content

Commit

Permalink
Merge pull request #51 from atarnvik/feature/improved-error-response-…
Browse files Browse the repository at this point in the history
…codes

Improve HTTP error response codes
  • Loading branch information
beetlebugorg authored Aug 9, 2024
2 parents 5a46277 + ffe2562 commit 12ba4dc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mod_dims.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,13 @@ dims_send_image(dims_request_rec *d)
} else if (d->fetch_http_status != 0) {
d->r->status = d->fetch_http_status;
} else if(d->status != DIMS_SUCCESS) {
d->r->status = HTTP_INTERNAL_SERVER_ERROR;
if (d->status == DIMS_BAD_URL
|| d->status == DIMS_BAD_ARGUMENTS) {
d->r->status = HTTP_BAD_REQUEST;
} else {
//Includes DIMS_BAD_CLIENT, DIMS_DOWNLOAD_TIMEOUT, DIMS_IMAGEMAGICK_TIMEOUT, DIMS_HOSTNAME_NOT_IN_WHITELIST
d->r->status = HTTP_INTERNAL_SERVER_ERROR;
}
}

if (blob == NULL) {
Expand Down Expand Up @@ -1379,7 +1385,7 @@ dims_handle_request(dims_request_rec *d)
gen_hash[7] = '\0';
ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0, d->r,
"Developer key not set for client '%s'", d->client_config->id);
return dims_cleanup(d, "Missing Developer Key", DIMS_BAD_URL);
return dims_cleanup(d, "Missing Developer Key", DIMS_BAD_CLIENT);
} else if (strncasecmp(hash, gen_hash, 6) != 0) {
gen_hash[7] = '\0';
ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0, d->r,
Expand Down

0 comments on commit 12ba4dc

Please sign in to comment.