1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <fcntl.h>
 4 #include <unistd.h>
 5 #include "config.h"
 6 #include "client.h"
 7 #include "server.h"
 8 #include "rh_string.h"
 9 #include "handler.h"
10 #include "http_request.h"
11 #include "rh_chunk.h"
12 
13 /*
14  *
15  * range
16  *
17  *
18  *
19  */
20 
21 
22 DECLARE_HANDLER_FUNCTION (range,exec)
23 {
24         http_request_t          *request, *sub;
25         http_header_entry_t     *range_header;
26         
27 #ifdef RHTTPD_DUMP_HANDLER_CALL
28         printf ("%s(%p)\n", __FUNCTION__, (void*)handler);
29 #endif
30         request = handler->request;
31         
32         range_header = http_header_key_get (&request->header_in,
33                         HTTP_HEADER_KEY_RANGE);
34 
35         if (NULL == range_header || ! range_header->found)
36                 return HANDLER_SUCCESS;
37 
38         sub = http_sub_request_alloc (request);
39         if (NULL == sub)
40                 return HANDLER_FAILURE;
41 
42         SIMPLEQ_INSERT_TAIL(&request->sub_request, sub, request);
43         sub->sub_request_number = 1;
44 
45         if (0 != handler_base_append_handler (&sub->handler, handler))
46                 return HANDLER_FAILURE;
47 
48         
49         return HANDLER_SUCCESS;
50 }
51 
52 
53 DECLARE_HANDLER_BEGIN (range, CONTENT)
54         .DECLARE_HANDLER_NULL   (range, setup),
55         .DECLARE_HANDLER_NULL   (range, init),
56         .DECLARE_HANDLER_NULL   (range, init_global),
57         .DECLARE_HANDLER_NULL   (range, free),
58         .DECLARE_HANDLER_NULL   (range, free_global),
59         .DECLARE_HANDLER_SYMBOL (range, exec),
60 DECLARE_HANDLER_END


syntax highlighted by Code2HTML, v. 0.9.1