[PATCH 00/17] HTTP response code improvements

John Keeping john at keeping.me.uk
Sun Apr 5 17:54:46 CEST 2015


Following Nicolas' report[0] about CGit caching error pages I've been
looking into ways of (optionally) avoiding caching error responses.

This series doesn't achieve that but it does give us two features that
will help to do so (neither of which are the case without this series of
patches):

1) Always return an HTTP error code if something goes wrong
2) Always set "ctx.page.status" when returning an error page

Without these changes CGit generally returns a "200 OK" response if
anything goes wrong after we have parsed the URL and found the
repository.  For example: unrecognised refs, unknown paths in trees,
corrupt objects in the repository.  This change requires moving the
layout start and end code into the individual page printing functions so
that we can delay printing the HTTP headers until we have resolved all
of the request parameters.

A more controversial change in this series is that we now always
generate an HTML response when an error occurs.  There are several cases
where this means that a response body will now be returned where there
was none before.  I think this is generally better, but I could be
convinced that there are some cases where we should not do this.

[0] http://lists.zx2c4.com/pipermail/cgit/2015-March/002464.html

John Keeping (17):
  ui-shared: add cgit_print_error_page() function
  cgit: use cgit_print_error_page() where appropriate
  clone: use cgit_print_error_page() instead of html_status()
  plain: use cgit_print_error_page() instead of html_status()
  snapshot: use cgit_print_error_page() instead of html_status()
  html: remove html_status()
  ui-shared: add cgit_print_layout_{start,end}()
  about: move layout into page functions
  commit: move layout into page function
  diff: move layout to page function
  log: move layout into page function
  refs: move layout to page function
  stats: move layout into page function
  summary: move layout into page function
  tag: move layout into page function
  tree: move layout into page function
  cmd: remove "want_layout" field

 cgit.c        | 36 +++++++-----------------------------
 cmd.c         | 44 ++++++++++++++++++++++----------------------
 cmd.h         |  1 -
 html.c        |  7 -------
 html.h        |  1 -
 ui-clone.c    | 10 +++++-----
 ui-commit.c   |  8 ++++++--
 ui-diff.c     | 19 ++++++++++++++-----
 ui-log.c      |  5 ++++-
 ui-plain.c    | 10 +++++-----
 ui-refs.c     |  3 ++-
 ui-repolist.c |  5 ++++-
 ui-shared.c   | 26 ++++++++++++++++++++++++++
 ui-shared.h   |  5 +++++
 ui-snapshot.c |  2 +-
 ui-stats.c    |  8 ++++++--
 ui-summary.c  | 10 ++++++++--
 ui-tag.c      | 13 ++++++++++---
 ui-tree.c     | 13 ++++++++++---
 19 files changed, 135 insertions(+), 91 deletions(-)

-- 
2.4.0.rc0.173.gb1cefcc



More information about the CGit mailing list