• Dag Erling Smørgrav's avatar
    Add an API for synthetic objects, and use it to implement negative · 4a5e0e8e
    Dag Erling Smørgrav authored
    caching of backend issues.
    
    Brief summary:
    
     - moved http_msg array from cache_response.c to cache_http.c,
       introduced http_StatusMessage() lookup function
    
     - introduced http_Put{Protocol,Status,Response} to complement
       http_PrintfHeader().
    
     - introduced SYN_ErrorPage() in a new file, cache_synthetic.c.
       SYN_ErrorPage() populates the session's current object with the
       specified error code and a corresponding HTML error page; it is the
       caller's responsibility to ensure that the session has a suitable
       object (i.e. one that doesn't already have headers or a body)
    
     - rewrote RES_Error() to simply call SYN_ErrorPage() (with ttl = 0) and
       RES_WriteObj().
    
     - rewrote cnt_fetch() to use SYN_ErrorPage() to create a 503 page with
       a TTL of 30 seconds when Fetch() fails.
    
     - removed the call to RES_Error() in cache_backend.c; the error
       trickles back up to cnt_fetch() anyway.
    
    Comments from review:
    
     - Memory allocation and pointer gymnastics for the header and body
       are duplicated all over the place (in new and pre-existing code)
       and should be centralized and hidden behind a suitable API.
    
     - The http_*() API needs refactoring, we shouldn't need four
       different functions to manipulate four different entries in the
       same array.
    
    
    git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1474 d4fa192b-c00b-0410-8231-f00ffab90ce4
    4a5e0e8e
cache_synthetic.c 4.29 KB