~ubuntu-branches/ubuntu/lucid/bind9/lucid

« back to all changes in this revision

Viewing changes to lib/isc/httpd.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2010-03-01 20:51:23 UTC
  • mfrom: (1.6.4 upstream) (10.1.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20100301205123-kslpwaipx72vq1o1
Tags: 1:9.7.0.dfsg-1~build1
upload of -1 to lucid, LP#530107

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2006-2008  Internet Systems Consortium, Inc. ("ISC")
 
2
 * Copyright (C) 2006-2008, 2010  Internet Systems Consortium, Inc. ("ISC")
3
3
 *
4
4
 * Permission to use, copy, modify, and/or distribute this software for any
5
5
 * purpose with or without fee is hereby granted, provided that the above
14
14
 * PERFORMANCE OF THIS SOFTWARE.
15
15
 */
16
16
 
17
 
/* $Id: httpd.c,v 1.16 2008/08/08 05:06:49 marka Exp $ */
 
17
/* $Id: httpd.c,v 1.16.284.2 2010/02/04 23:48:30 tbox Exp $ */
18
18
 
19
19
/*! \file */
20
20
 
151
151
 
152
152
        ISC_LIST(isc_httpdurl_t) urls;          /*%< urls we manage */
153
153
        isc_httpdaction_t      *render_404;
 
154
        isc_httpdaction_t      *render_500;
154
155
};
155
156
 
156
157
/*%
221
222
                               unsigned int *, const char **,
222
223
                               const char **, isc_buffer_t *,
223
224
                               isc_httpdfree_t **, void **);
 
225
static isc_result_t render_500(const char *, const char *,
 
226
                               void *,
 
227
                               unsigned int *, const char **,
 
228
                               const char **, isc_buffer_t *,
 
229
                               isc_httpdfree_t **, void **);
224
230
 
225
231
static void
226
232
destroy_client(isc_httpd_t **httpdp)
300
306
                goto cleanup;
301
307
 
302
308
        httpd->render_404 = render_404;
 
309
        httpd->render_500 = render_500;
303
310
 
304
311
        *httpdp = httpd;
305
312
        return (ISC_R_SUCCESS);
623
630
        return (ISC_R_SUCCESS);
624
631
}
625
632
 
 
633
static isc_result_t
 
634
render_500(const char *url, const char *querystring,
 
635
           void *arg,
 
636
           unsigned int *retcode, const char **retmsg,
 
637
           const char **mimetype, isc_buffer_t *b,
 
638
           isc_httpdfree_t **freecb, void **freecb_args)
 
639
{
 
640
        static char msg[] = "Internal server failure.";
 
641
 
 
642
        UNUSED(url);
 
643
        UNUSED(querystring);
 
644
        UNUSED(arg);
 
645
 
 
646
        *retcode = 500;
 
647
        *retmsg = "Internal server failure";
 
648
        *mimetype = "text/plain";
 
649
        isc_buffer_reinit(b, msg, strlen(msg));
 
650
        isc_buffer_add(b, strlen(msg));
 
651
        *freecb = NULL;
 
652
        *freecb_args = NULL;
 
653
 
 
654
        return (ISC_R_SUCCESS);
 
655
}
 
656
 
626
657
static void
627
658
isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev)
628
659
{
691
722
                                     &httpd->mimetype, &httpd->bodybuffer,
692
723
                                     &httpd->freecb, &httpd->freecb_arg);
693
724
        if (result != ISC_R_SUCCESS) {
694
 
                destroy_client(&httpd);
695
 
                goto out;
 
725
            result = httpd->mgr->render_500(httpd->url, httpd->querystring,
 
726
                                            NULL,
 
727
                                            &httpd->retcode,
 
728
                                            &httpd->retmsg,
 
729
                                            &httpd->mimetype,
 
730
                                            &httpd->bodybuffer,
 
731
                                            &httpd->freecb,
 
732
                                            &httpd->freecb_arg);
696
733
        }
697
734
 
698
735
        isc_httpd_response(httpd);