X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=frontend%2Fcgi%2Fcgi.c;h=3ebd3a09f97af61984101961853b74f471b56a30;hb=785335ab3930a325acd888bfb6b3ad542c619588;hp=6403273c31970b09ce071dc5760a91da8bb5d9b1;hpb=752ea52c468480eab4519f5a0227a9e3904a7813;p=cascardo%2Fatompub.git 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 {