From: Thadeu Lima de Souza Cascardo Date: Sun, 27 Jan 2008 04:43:24 +0000 (-0200) Subject: Returns HTTP error if some error has been found while serving the file. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fatompub.git;a=commitdiff_plain;h=785335ab3930a325acd888bfb6b3ad542c619588 Returns HTTP error if some error has been found while serving the file. --- diff --git a/frontend/cgi/cgi.c b/frontend/cgi/cgi.c index 6403273..3ebd3a0 100644 --- a/frontend/cgi/cgi.c +++ b/frontend/cgi/cgi.c @@ -39,6 +39,7 @@ cgi_serve_request (AtomCtx *ctx) { IRI *iri = iri_new (); Atom *atom; + GError *error; iri_set_path (iri, path); atom = atom_retrieve_resource (ctx, iri); iri_delete (iri); @@ -49,6 +50,19 @@ cgi_serve_request (AtomCtx *ctx) write (1, atom_string (atom), atom_len (atom)); atom_delete (atom); } + else if ((error = atom_error_get (ctx)) != NULL) + { + if (error->domain == G_FILE_ERROR && + (error->code == G_FILE_ERROR_EXIST || + error->code == G_FILE_ERROR_ACCESS || + error->code == G_FILE_ERROR_PERM)) + fprintf (stdout, "Status: 403 %s\n\n", err->message); + else if (error->domain == G_FILE_ERROR && + error->code == G_FILE_ERROR_NOENT) + fprintf (stdout, "Status: 404 %s\n\n", err->message); + else + fprintf (stdout, "Status: 500 %s\n\n", err->message); + } } else {