CINXE.COM
[Apache-SVN] Contents of /httpd/flood/trunk/flood_socket_keepalive.c
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- ViewVC :: http://www.viewvc.org/ --> <head> <title>[Apache-SVN] Contents of /httpd/flood/trunk/flood_socket_keepalive.c</title> <meta name="generator" content="ViewVC 1.1.26" /> <link rel="shortcut icon" href="/vc-static/images/favicon.ico" /> <link rel="stylesheet" href="/vc-static/styles.css" type="text/css" /> </head> <body> <div class="vc_navheader"> <table><tr> <td><strong><a href="/viewvc?sortby=rev&view=roots"><span class="pathdiv">/</span></a><a href="/viewvc/?sortby=rev&pathrev=699195">[Apache-SVN]</a><span class="pathdiv">/</span><a href="/viewvc/httpd/?sortby=rev&pathrev=699195">httpd</a><span class="pathdiv">/</span><a href="/viewvc/httpd/flood/?sortby=rev&pathrev=699195">flood</a><span class="pathdiv">/</span><a href="/viewvc/httpd/flood/trunk/?sortby=rev&pathrev=699195">trunk</a><span class="pathdiv">/</span><a href="/viewvc/httpd/flood/trunk/flood_socket_keepalive.c?view=log&sortby=rev&pathrev=699195">flood_socket_keepalive.c</a></strong></td> <td style="text-align: right;"></td> </tr></table> </div> <div style="float: right; padding: 5px;"><a href="http://www.viewvc.org/" title="ViewVC Home"><img src="/vc-static/images/viewvc-logo.png" alt="ViewVC logotype" width="240" height="70" /></a></div> <h1>Contents of /httpd/flood/trunk/flood_socket_keepalive.c</h1> <p style="margin:0;"> <a href="/viewvc/httpd/flood/trunk/?sortby=rev&pathrev=699195"><img src="/vc-static/images/back_small.png" class="vc_icon" alt="Parent Directory" /> Parent Directory</a> | <a href="/viewvc/httpd/flood/trunk/flood_socket_keepalive.c?view=log&sortby=rev&pathrev=699195"><img src="/vc-static/images/log.png" class="vc_icon" alt="Revision Log" /> Revision Log</a> </p> <hr /> <div class="vc_summary"> Revision <a href="/viewvc?view=revision&sortby=rev&revision=699195"><strong>699195</strong></a> - (<a href="/viewvc/httpd/flood/trunk/flood_socket_keepalive.c?annotate=699195&sortby=rev&pathrev=699195"><strong>show annotations</strong></a>) (<a href="/viewvc/httpd/flood/trunk/flood_socket_keepalive.c?revision=699195&view=co&pathrev=699195"><strong>download</strong></a>) <br /><em>Fri Sep 26 06:53:51 2008 UTC</em> (16 years, 2 months ago) by <em>jerenkrantz</em> <br />File MIME type: text/plain <br />File size: 16785 byte(s) <pre class="vc_log">Fix issue with chunked keep-alive responses when the initial chunk content starts with a NULL byte. * flood_socket_keepalive.c (keepalive_read_chunk): Don't inspect resp->chunk with respect to validity; re-order comparisons to make a bit more sense. (keepalive_recv_resp): Be sure that chunk_length is always initialized. </pre> </div> <div id="vc_file"> <table cellspacing="0" cellpadding="0"> <tr class="vc_row_odd" id="l1"> <td class="vc_file_line_number"><a href="#l1">1</a></td> <td class="vc_file_line_text">/* Licensed to the Apache Software Foundation (ASF) under one or more</td> </tr> <tr class="vc_row_odd" id="l2"> <td class="vc_file_line_number"><a href="#l2">2</a></td> <td class="vc_file_line_text"> * contributor license agreements. See the NOTICE file distributed with</td> </tr> <tr class="vc_row_odd" id="l3"> <td class="vc_file_line_number"><a href="#l3">3</a></td> <td class="vc_file_line_text"> * this work for additional information regarding copyright ownership.</td> </tr> <tr class="vc_row_odd" id="l4"> <td class="vc_file_line_number"><a href="#l4">4</a></td> <td class="vc_file_line_text"> * The ASF licenses this file to You under the Apache License, Version 2.0</td> </tr> <tr class="vc_row_odd" id="l5"> <td class="vc_file_line_number"><a href="#l5">5</a></td> <td class="vc_file_line_text"> * (the "License"); you may not use this file except in compliance with</td> </tr> <tr class="vc_row_odd" id="l6"> <td class="vc_file_line_number"><a href="#l6">6</a></td> <td class="vc_file_line_text"> * the License. You may obtain a copy of the License at</td> </tr> <tr class="vc_row_odd" id="l7"> <td class="vc_file_line_number"><a href="#l7">7</a></td> <td class="vc_file_line_text"> *</td> </tr> <tr class="vc_row_odd" id="l8"> <td class="vc_file_line_number"><a href="#l8">8</a></td> <td class="vc_file_line_text"> * <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a></td> </tr> <tr class="vc_row_odd" id="l9"> <td class="vc_file_line_number"><a href="#l9">9</a></td> <td class="vc_file_line_text"> *</td> </tr> <tr class="vc_row_odd" id="l10"> <td class="vc_file_line_number"><a href="#l10">10</a></td> <td class="vc_file_line_text"> * Unless required by applicable law or agreed to in writing, software</td> </tr> <tr class="vc_row_odd" id="l11"> <td class="vc_file_line_number"><a href="#l11">11</a></td> <td class="vc_file_line_text"> * distributed under the License is distributed on an "AS IS" BASIS,</td> </tr> <tr class="vc_row_odd" id="l12"> <td class="vc_file_line_number"><a href="#l12">12</a></td> <td class="vc_file_line_text"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</td> </tr> <tr class="vc_row_odd" id="l13"> <td class="vc_file_line_number"><a href="#l13">13</a></td> <td class="vc_file_line_text"> * See the License for the specific language governing permissions and</td> </tr> <tr class="vc_row_odd" id="l14"> <td class="vc_file_line_number"><a href="#l14">14</a></td> <td class="vc_file_line_text"> * limitations under the License.</td> </tr> <tr class="vc_row_odd" id="l15"> <td class="vc_file_line_number"><a href="#l15">15</a></td> <td class="vc_file_line_text"> *</td> </tr> <tr class="vc_row_odd" id="l16"> <td class="vc_file_line_number"><a href="#l16">16</a></td> <td class="vc_file_line_text"> * Originally developed by Aaron Bannert and Justin Erenkrantz, eBuilt.</td> </tr> <tr class="vc_row_odd" id="l17"> <td class="vc_file_line_number"><a href="#l17">17</a></td> <td class="vc_file_line_text"> */</td> </tr> <tr class="vc_row_odd" id="l18"> <td class="vc_file_line_number"><a href="#l18">18</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l19"> <td class="vc_file_line_number"><a href="#l19">19</a></td> <td class="vc_file_line_text">#include <apr.h></td> </tr> <tr class="vc_row_odd" id="l20"> <td class="vc_file_line_number"><a href="#l20">20</a></td> <td class="vc_file_line_text">#include <apr_strings.h></td> </tr> <tr class="vc_row_odd" id="l21"> <td class="vc_file_line_number"><a href="#l21">21</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l22"> <td class="vc_file_line_number"><a href="#l22">22</a></td> <td class="vc_file_line_text">#if APR_HAVE_STDLIB_H</td> </tr> <tr class="vc_row_odd" id="l23"> <td class="vc_file_line_number"><a href="#l23">23</a></td> <td class="vc_file_line_text">#include <stdlib.h> /* rand/strtol */</td> </tr> <tr class="vc_row_odd" id="l24"> <td class="vc_file_line_number"><a href="#l24">24</a></td> <td class="vc_file_line_text">#endif</td> </tr> <tr class="vc_row_odd" id="l25"> <td class="vc_file_line_number"><a href="#l25">25</a></td> <td class="vc_file_line_text">#if APR_HAVE_STRING_H</td> </tr> <tr class="vc_row_odd" id="l26"> <td class="vc_file_line_number"><a href="#l26">26</a></td> <td class="vc_file_line_text">#include <string.h></td> </tr> <tr class="vc_row_odd" id="l27"> <td class="vc_file_line_number"><a href="#l27">27</a></td> <td class="vc_file_line_text">#endif</td> </tr> <tr class="vc_row_odd" id="l28"> <td class="vc_file_line_number"><a href="#l28">28</a></td> <td class="vc_file_line_text">#include <assert.h></td> </tr> <tr class="vc_row_odd" id="l29"> <td class="vc_file_line_number"><a href="#l29">29</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l30"> <td class="vc_file_line_number"><a href="#l30">30</a></td> <td class="vc_file_line_text">#include "config.h"</td> </tr> <tr class="vc_row_odd" id="l31"> <td class="vc_file_line_number"><a href="#l31">31</a></td> <td class="vc_file_line_text">#include "flood_net.h"</td> </tr> <tr class="vc_row_odd" id="l32"> <td class="vc_file_line_number"><a href="#l32">32</a></td> <td class="vc_file_line_text">#include "flood_net_ssl.h"</td> </tr> <tr class="vc_row_odd" id="l33"> <td class="vc_file_line_number"><a href="#l33">33</a></td> <td class="vc_file_line_text">#include "flood_socket_keepalive.h"</td> </tr> <tr class="vc_row_odd" id="l34"> <td class="vc_file_line_number"><a href="#l34">34</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l35"> <td class="vc_file_line_number"><a href="#l35">35</a></td> <td class="vc_file_line_text">#define ksock_read_socket(ksock, buf, lenaddr) \</td> </tr> <tr class="vc_row_odd" id="l36"> <td class="vc_file_line_number"><a href="#l36">36</a></td> <td class="vc_file_line_text"> ksock->ssl ? ssl_read_socket(ksock->s, buf, lenaddr) : \</td> </tr> <tr class="vc_row_odd" id="l37"> <td class="vc_file_line_number"><a href="#l37">37</a></td> <td class="vc_file_line_text"> read_socket(ksock->s, buf, lenaddr)</td> </tr> <tr class="vc_row_odd" id="l38"> <td class="vc_file_line_number"><a href="#l38">38</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l39"> <td class="vc_file_line_number"><a href="#l39">39</a></td> <td class="vc_file_line_text">#define ksock_write_socket(ksock, req) \</td> </tr> <tr class="vc_row_odd" id="l40"> <td class="vc_file_line_number"><a href="#l40">40</a></td> <td class="vc_file_line_text"> ksock->ssl ? ssl_write_socket(ksock->s, req) : \</td> </tr> <tr class="vc_row_odd" id="l41"> <td class="vc_file_line_number"><a href="#l41">41</a></td> <td class="vc_file_line_text"> write_socket(ksock->s, req)</td> </tr> <tr class="vc_row_odd" id="l42"> <td class="vc_file_line_number"><a href="#l42">42</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l43"> <td class="vc_file_line_number"><a href="#l43">43</a></td> <td class="vc_file_line_text">#define ksock_check_socket(ksock, pool) \</td> </tr> <tr class="vc_row_odd" id="l44"> <td class="vc_file_line_number"><a href="#l44">44</a></td> <td class="vc_file_line_text"> ksock->ssl ? ssl_check_socket(ksock->s, pool) : \</td> </tr> <tr class="vc_row_odd" id="l45"> <td class="vc_file_line_number"><a href="#l45">45</a></td> <td class="vc_file_line_text"> check_socket(ksock->s, pool)</td> </tr> <tr class="vc_row_odd" id="l46"> <td class="vc_file_line_number"><a href="#l46">46</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l47"> <td class="vc_file_line_number"><a href="#l47">47</a></td> <td class="vc_file_line_text">#define ksock_close_socket(ksock) \</td> </tr> <tr class="vc_row_odd" id="l48"> <td class="vc_file_line_number"><a href="#l48">48</a></td> <td class="vc_file_line_text"> ksock->ssl ? ssl_close_socket(ksock->s) : \</td> </tr> <tr class="vc_row_odd" id="l49"> <td class="vc_file_line_number"><a href="#l49">49</a></td> <td class="vc_file_line_text"> close_socket(ksock->s)</td> </tr> <tr class="vc_row_odd" id="l50"> <td class="vc_file_line_number"><a href="#l50">50</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l51"> <td class="vc_file_line_number"><a href="#l51">51</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l52"> <td class="vc_file_line_number"><a href="#l52">52</a></td> <td class="vc_file_line_text">typedef struct {</td> </tr> <tr class="vc_row_odd" id="l53"> <td class="vc_file_line_number"><a href="#l53">53</a></td> <td class="vc_file_line_text"> void *s;</td> </tr> <tr class="vc_row_odd" id="l54"> <td class="vc_file_line_number"><a href="#l54">54</a></td> <td class="vc_file_line_text"> apr_pollfd_t *p;</td> </tr> <tr class="vc_row_odd" id="l55"> <td class="vc_file_line_number"><a href="#l55">55</a></td> <td class="vc_file_line_text"> int reopen_socket; /* A boolean */</td> </tr> <tr class="vc_row_odd" id="l56"> <td class="vc_file_line_number"><a href="#l56">56</a></td> <td class="vc_file_line_text"> int wantresponse; /* A boolean */</td> </tr> <tr class="vc_row_odd" id="l57"> <td class="vc_file_line_number"><a href="#l57">57</a></td> <td class="vc_file_line_text"> int ssl; /* A boolean */</td> </tr> <tr class="vc_row_odd" id="l58"> <td class="vc_file_line_number"><a href="#l58">58</a></td> <td class="vc_file_line_text"> method_e method; /* The method of the request. */</td> </tr> <tr class="vc_row_odd" id="l59"> <td class="vc_file_line_number"><a href="#l59">59</a></td> <td class="vc_file_line_text">} keepalive_socket_t;</td> </tr> <tr class="vc_row_odd" id="l60"> <td class="vc_file_line_number"><a href="#l60">60</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l61"> <td class="vc_file_line_number"><a href="#l61">61</a></td> <td class="vc_file_line_text">/**</td> </tr> <tr class="vc_row_odd" id="l62"> <td class="vc_file_line_number"><a href="#l62">62</a></td> <td class="vc_file_line_text"> * Keep-alive implementation for socket_init.</td> </tr> <tr class="vc_row_odd" id="l63"> <td class="vc_file_line_number"><a href="#l63">63</a></td> <td class="vc_file_line_text"> */</td> </tr> <tr class="vc_row_odd" id="l64"> <td class="vc_file_line_number"><a href="#l64">64</a></td> <td class="vc_file_line_text">apr_status_t keepalive_socket_init(socket_t **sock, apr_pool_t *pool)</td> </tr> <tr class="vc_row_odd" id="l65"> <td class="vc_file_line_number"><a href="#l65">65</a></td> <td class="vc_file_line_text">{</td> </tr> <tr class="vc_row_odd" id="l66"> <td class="vc_file_line_number"><a href="#l66">66</a></td> <td class="vc_file_line_text"> keepalive_socket_t *new_ksock;</td> </tr> <tr class="vc_row_odd" id="l67"> <td class="vc_file_line_number"><a href="#l67">67</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l68"> <td class="vc_file_line_number"><a href="#l68">68</a></td> <td class="vc_file_line_text"> new_ksock = (keepalive_socket_t *)apr_palloc(pool, sizeof(keepalive_socket_t));</td> </tr> <tr class="vc_row_odd" id="l69"> <td class="vc_file_line_number"><a href="#l69">69</a></td> <td class="vc_file_line_text"> if (new_ksock == NULL)</td> </tr> <tr class="vc_row_odd" id="l70"> <td class="vc_file_line_number"><a href="#l70">70</a></td> <td class="vc_file_line_text"> return APR_ENOMEM;</td> </tr> <tr class="vc_row_odd" id="l71"> <td class="vc_file_line_number"><a href="#l71">71</a></td> <td class="vc_file_line_text"> new_ksock->s = NULL;</td> </tr> <tr class="vc_row_odd" id="l72"> <td class="vc_file_line_number"><a href="#l72">72</a></td> <td class="vc_file_line_text"> new_ksock->p = NULL;</td> </tr> <tr class="vc_row_odd" id="l73"> <td class="vc_file_line_number"><a href="#l73">73</a></td> <td class="vc_file_line_text"> new_ksock->reopen_socket = 1;</td> </tr> <tr class="vc_row_odd" id="l74"> <td class="vc_file_line_number"><a href="#l74">74</a></td> <td class="vc_file_line_text"> new_ksock->wantresponse = 1;</td> </tr> <tr class="vc_row_odd" id="l75"> <td class="vc_file_line_number"><a href="#l75">75</a></td> <td class="vc_file_line_text"> new_ksock->ssl = 0;</td> </tr> <tr class="vc_row_odd" id="l76"> <td class="vc_file_line_number"><a href="#l76">76</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l77"> <td class="vc_file_line_number"><a href="#l77">77</a></td> <td class="vc_file_line_text"> *sock = new_ksock;</td> </tr> <tr class="vc_row_odd" id="l78"> <td class="vc_file_line_number"><a href="#l78">78</a></td> <td class="vc_file_line_text"> return APR_SUCCESS;</td> </tr> <tr class="vc_row_odd" id="l79"> <td class="vc_file_line_number"><a href="#l79">79</a></td> <td class="vc_file_line_text">}</td> </tr> <tr class="vc_row_odd" id="l80"> <td class="vc_file_line_number"><a href="#l80">80</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l81"> <td class="vc_file_line_number"><a href="#l81">81</a></td> <td class="vc_file_line_text">/**</td> </tr> <tr class="vc_row_odd" id="l82"> <td class="vc_file_line_number"><a href="#l82">82</a></td> <td class="vc_file_line_text"> * Keep-alive implementation for begin_conn.</td> </tr> <tr class="vc_row_odd" id="l83"> <td class="vc_file_line_number"><a href="#l83">83</a></td> <td class="vc_file_line_text"> */</td> </tr> <tr class="vc_row_odd" id="l84"> <td class="vc_file_line_number"><a href="#l84">84</a></td> <td class="vc_file_line_text">apr_status_t keepalive_begin_conn(socket_t *sock, request_t *req, apr_pool_t *pool)</td> </tr> <tr class="vc_row_odd" id="l85"> <td class="vc_file_line_number"><a href="#l85">85</a></td> <td class="vc_file_line_text">{</td> </tr> <tr class="vc_row_odd" id="l86"> <td class="vc_file_line_number"><a href="#l86">86</a></td> <td class="vc_file_line_text"> keepalive_socket_t *ksock = (keepalive_socket_t *)sock;</td> </tr> <tr class="vc_row_odd" id="l87"> <td class="vc_file_line_number"><a href="#l87">87</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l88"> <td class="vc_file_line_number"><a href="#l88">88</a></td> <td class="vc_file_line_text"> if (!ksock->reopen_socket && ksock->s) {</td> </tr> <tr class="vc_row_odd" id="l89"> <td class="vc_file_line_number"><a href="#l89">89</a></td> <td class="vc_file_line_text"> apr_status_t e;</td> </tr> <tr class="vc_row_odd" id="l90"> <td class="vc_file_line_number"><a href="#l90">90</a></td> <td class="vc_file_line_text"> e = ksock_check_socket(ksock, pool);</td> </tr> <tr class="vc_row_odd" id="l91"> <td class="vc_file_line_number"><a href="#l91">91</a></td> <td class="vc_file_line_text"> if (e != APR_SUCCESS) {</td> </tr> <tr class="vc_row_odd" id="l92"> <td class="vc_file_line_number"><a href="#l92">92</a></td> <td class="vc_file_line_text"> ksock->reopen_socket = 1;</td> </tr> <tr class="vc_row_odd" id="l93"> <td class="vc_file_line_number"><a href="#l93">93</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l94"> <td class="vc_file_line_number"><a href="#l94">94</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l95"> <td class="vc_file_line_number"><a href="#l95">95</a></td> <td class="vc_file_line_text"> if (ksock->reopen_socket || ksock->s == NULL) {</td> </tr> <tr class="vc_row_odd" id="l96"> <td class="vc_file_line_number"><a href="#l96">96</a></td> <td class="vc_file_line_text"> apr_status_t rv;</td> </tr> <tr class="vc_row_odd" id="l97"> <td class="vc_file_line_number"><a href="#l97">97</a></td> <td class="vc_file_line_text"> if (strcasecmp(req->parsed_uri->scheme, "https") == 0) {</td> </tr> <tr class="vc_row_odd" id="l98"> <td class="vc_file_line_number"><a href="#l98">98</a></td> <td class="vc_file_line_text"> /* If we don't have SSL, error out. */</td> </tr> <tr class="vc_row_odd" id="l99"> <td class="vc_file_line_number"><a href="#l99">99</a></td> <td class="vc_file_line_text">#if FLOOD_HAS_OPENSSL</td> </tr> <tr class="vc_row_odd" id="l100"> <td class="vc_file_line_number"><a href="#l100">100</a></td> <td class="vc_file_line_text"> ksock->ssl = 1;</td> </tr> <tr class="vc_row_odd" id="l101"> <td class="vc_file_line_number"><a href="#l101">101</a></td> <td class="vc_file_line_text">#else</td> </tr> <tr class="vc_row_odd" id="l102"> <td class="vc_file_line_number"><a href="#l102">102</a></td> <td class="vc_file_line_text"> return APR_ENOTIMPL;</td> </tr> <tr class="vc_row_odd" id="l103"> <td class="vc_file_line_number"><a href="#l103">103</a></td> <td class="vc_file_line_text">#endif</td> </tr> <tr class="vc_row_odd" id="l104"> <td class="vc_file_line_number"><a href="#l104">104</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l105"> <td class="vc_file_line_number"><a href="#l105">105</a></td> <td class="vc_file_line_text"> else {</td> </tr> <tr class="vc_row_odd" id="l106"> <td class="vc_file_line_number"><a href="#l106">106</a></td> <td class="vc_file_line_text"> ksock->ssl = 0;</td> </tr> <tr class="vc_row_odd" id="l107"> <td class="vc_file_line_number"><a href="#l107">107</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l108"> <td class="vc_file_line_number"><a href="#l108">108</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l109"> <td class="vc_file_line_number"><a href="#l109">109</a></td> <td class="vc_file_line_text"> /* The return types are not identical, so it can't be a ternary</td> </tr> <tr class="vc_row_odd" id="l110"> <td class="vc_file_line_number"><a href="#l110">110</a></td> <td class="vc_file_line_text"> * operation. */</td> </tr> <tr class="vc_row_odd" id="l111"> <td class="vc_file_line_number"><a href="#l111">111</a></td> <td class="vc_file_line_text"> if (ksock->ssl)</td> </tr> <tr class="vc_row_odd" id="l112"> <td class="vc_file_line_number"><a href="#l112">112</a></td> <td class="vc_file_line_text"> ksock->s = ssl_open_socket(pool, req, &rv);</td> </tr> <tr class="vc_row_odd" id="l113"> <td class="vc_file_line_number"><a href="#l113">113</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l114"> <td class="vc_file_line_number"><a href="#l114">114</a></td> <td class="vc_file_line_text"> ksock->s = open_socket(pool, req, &rv);</td> </tr> <tr class="vc_row_odd" id="l115"> <td class="vc_file_line_number"><a href="#l115">115</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l116"> <td class="vc_file_line_number"><a href="#l116">116</a></td> <td class="vc_file_line_text"> if (ksock->s == NULL)</td> </tr> <tr class="vc_row_odd" id="l117"> <td class="vc_file_line_number"><a href="#l117">117</a></td> <td class="vc_file_line_text"> return rv;</td> </tr> <tr class="vc_row_odd" id="l118"> <td class="vc_file_line_number"><a href="#l118">118</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l119"> <td class="vc_file_line_number"><a href="#l119">119</a></td> <td class="vc_file_line_text"> ksock->reopen_socket = 0; /* we just opened it */</td> </tr> <tr class="vc_row_odd" id="l120"> <td class="vc_file_line_number"><a href="#l120">120</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l121"> <td class="vc_file_line_number"><a href="#l121">121</a></td> <td class="vc_file_line_text"> req->keepalive = 1;</td> </tr> <tr class="vc_row_odd" id="l122"> <td class="vc_file_line_number"><a href="#l122">122</a></td> <td class="vc_file_line_text"> return APR_SUCCESS;</td> </tr> <tr class="vc_row_odd" id="l123"> <td class="vc_file_line_number"><a href="#l123">123</a></td> <td class="vc_file_line_text">}</td> </tr> <tr class="vc_row_odd" id="l124"> <td class="vc_file_line_number"><a href="#l124">124</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l125"> <td class="vc_file_line_number"><a href="#l125">125</a></td> <td class="vc_file_line_text">/**</td> </tr> <tr class="vc_row_odd" id="l126"> <td class="vc_file_line_number"><a href="#l126">126</a></td> <td class="vc_file_line_text"> * Keep-alive implementation for send_req.</td> </tr> <tr class="vc_row_odd" id="l127"> <td class="vc_file_line_number"><a href="#l127">127</a></td> <td class="vc_file_line_text"> */</td> </tr> <tr class="vc_row_odd" id="l128"> <td class="vc_file_line_number"><a href="#l128">128</a></td> <td class="vc_file_line_text">apr_status_t keepalive_send_req(socket_t *sock, request_t *req, apr_pool_t *pool)</td> </tr> <tr class="vc_row_odd" id="l129"> <td class="vc_file_line_number"><a href="#l129">129</a></td> <td class="vc_file_line_text">{</td> </tr> <tr class="vc_row_odd" id="l130"> <td class="vc_file_line_number"><a href="#l130">130</a></td> <td class="vc_file_line_text"> keepalive_socket_t *ksock = (keepalive_socket_t *)sock;</td> </tr> <tr class="vc_row_odd" id="l131"> <td class="vc_file_line_number"><a href="#l131">131</a></td> <td class="vc_file_line_text"> ksock->wantresponse = req->wantresponse;</td> </tr> <tr class="vc_row_odd" id="l132"> <td class="vc_file_line_number"><a href="#l132">132</a></td> <td class="vc_file_line_text"> ksock->method = req->method;</td> </tr> <tr class="vc_row_odd" id="l133"> <td class="vc_file_line_number"><a href="#l133">133</a></td> <td class="vc_file_line_text"> return ksock->ssl ? ssl_write_socket(ksock->s, req) :</td> </tr> <tr class="vc_row_odd" id="l134"> <td class="vc_file_line_number"><a href="#l134">134</a></td> <td class="vc_file_line_text"> write_socket(ksock->s, req);</td> </tr> <tr class="vc_row_odd" id="l135"> <td class="vc_file_line_number"><a href="#l135">135</a></td> <td class="vc_file_line_text">}</td> </tr> <tr class="vc_row_odd" id="l136"> <td class="vc_file_line_number"><a href="#l136">136</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l137"> <td class="vc_file_line_number"><a href="#l137">137</a></td> <td class="vc_file_line_text">static long keepalive_read_chunk_size(char *begin_chunk)</td> </tr> <tr class="vc_row_odd" id="l138"> <td class="vc_file_line_number"><a href="#l138">138</a></td> <td class="vc_file_line_text">{</td> </tr> <tr class="vc_row_odd" id="l139"> <td class="vc_file_line_number"><a href="#l139">139</a></td> <td class="vc_file_line_text"> char chunk[17], *end_chunk;</td> </tr> <tr class="vc_row_odd" id="l140"> <td class="vc_file_line_number"><a href="#l140">140</a></td> <td class="vc_file_line_text"> long chunk_length;</td> </tr> <tr class="vc_row_odd" id="l141"> <td class="vc_file_line_number"><a href="#l141">141</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l142"> <td class="vc_file_line_number"><a href="#l142">142</a></td> <td class="vc_file_line_text"> /* FIXME: Handle chunk-extension */</td> </tr> <tr class="vc_row_odd" id="l143"> <td class="vc_file_line_number"><a href="#l143">143</a></td> <td class="vc_file_line_text"> end_chunk = strstr(begin_chunk, CRLF);</td> </tr> <tr class="vc_row_odd" id="l144"> <td class="vc_file_line_number"><a href="#l144">144</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l145"> <td class="vc_file_line_number"><a href="#l145">145</a></td> <td class="vc_file_line_text"> if (end_chunk && end_chunk - begin_chunk < 16)</td> </tr> <tr class="vc_row_odd" id="l146"> <td class="vc_file_line_number"><a href="#l146">146</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l147"> <td class="vc_file_line_number"><a href="#l147">147</a></td> <td class="vc_file_line_text"> strncpy(chunk, begin_chunk, end_chunk - begin_chunk);</td> </tr> <tr class="vc_row_odd" id="l148"> <td class="vc_file_line_number"><a href="#l148">148</a></td> <td class="vc_file_line_text"> chunk[end_chunk-begin_chunk] = '\0';</td> </tr> <tr class="vc_row_odd" id="l149"> <td class="vc_file_line_number"><a href="#l149">149</a></td> <td class="vc_file_line_text"> /* Chunks are base-16 */</td> </tr> <tr class="vc_row_odd" id="l150"> <td class="vc_file_line_number"><a href="#l150">150</a></td> <td class="vc_file_line_text"> chunk_length = strtol(chunk, &end_chunk, 16);</td> </tr> <tr class="vc_row_odd" id="l151"> <td class="vc_file_line_number"><a href="#l151">151</a></td> <td class="vc_file_line_text"> if (*end_chunk == '\0')</td> </tr> <tr class="vc_row_odd" id="l152"> <td class="vc_file_line_number"><a href="#l152">152</a></td> <td class="vc_file_line_text"> return chunk_length;</td> </tr> <tr class="vc_row_odd" id="l153"> <td class="vc_file_line_number"><a href="#l153">153</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l154"> <td class="vc_file_line_number"><a href="#l154">154</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l155"> <td class="vc_file_line_number"><a href="#l155">155</a></td> <td class="vc_file_line_text"> return 0;</td> </tr> <tr class="vc_row_odd" id="l156"> <td class="vc_file_line_number"><a href="#l156">156</a></td> <td class="vc_file_line_text">}</td> </tr> <tr class="vc_row_odd" id="l157"> <td class="vc_file_line_number"><a href="#l157">157</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l158"> <td class="vc_file_line_number"><a href="#l158">158</a></td> <td class="vc_file_line_text">static apr_status_t keepalive_read_chunk(response_t *resp,</td> </tr> <tr class="vc_row_odd" id="l159"> <td class="vc_file_line_number"><a href="#l159">159</a></td> <td class="vc_file_line_text"> keepalive_socket_t *sock,</td> </tr> <tr class="vc_row_odd" id="l160"> <td class="vc_file_line_number"><a href="#l160">160</a></td> <td class="vc_file_line_text"> int chunk_length,</td> </tr> <tr class="vc_row_odd" id="l161"> <td class="vc_file_line_number"><a href="#l161">161</a></td> <td class="vc_file_line_text"> char **bp, int bplen)</td> </tr> <tr class="vc_row_odd" id="l162"> <td class="vc_file_line_number"><a href="#l162">162</a></td> <td class="vc_file_line_text">{</td> </tr> <tr class="vc_row_odd" id="l163"> <td class="vc_file_line_number"><a href="#l163">163</a></td> <td class="vc_file_line_text"> apr_status_t status = APR_SUCCESS;</td> </tr> <tr class="vc_row_odd" id="l164"> <td class="vc_file_line_number"><a href="#l164">164</a></td> <td class="vc_file_line_text"> int old_length = 0;</td> </tr> <tr class="vc_row_odd" id="l165"> <td class="vc_file_line_number"><a href="#l165">165</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l166"> <td class="vc_file_line_number"><a href="#l166">166</a></td> <td class="vc_file_line_text"> if (!resp->chunk) {</td> </tr> <tr class="vc_row_odd" id="l167"> <td class="vc_file_line_number"><a href="#l167">167</a></td> <td class="vc_file_line_text"> chunk_length = 0;</td> </tr> <tr class="vc_row_odd" id="l168"> <td class="vc_file_line_number"><a href="#l168">168</a></td> <td class="vc_file_line_text"> } else if (chunk_length < 0) {</td> </tr> <tr class="vc_row_odd" id="l169"> <td class="vc_file_line_number"><a href="#l169">169</a></td> <td class="vc_file_line_text"> old_length = chunk_length;</td> </tr> <tr class="vc_row_odd" id="l170"> <td class="vc_file_line_number"><a href="#l170">170</a></td> <td class="vc_file_line_text"> chunk_length = 0;</td> </tr> <tr class="vc_row_odd" id="l171"> <td class="vc_file_line_number"><a href="#l171">171</a></td> <td class="vc_file_line_text"> } else if (chunk_length == 0) {</td> </tr> <tr class="vc_row_odd" id="l172"> <td class="vc_file_line_number"><a href="#l172">172</a></td> <td class="vc_file_line_text"> return status;</td> </tr> <tr class="vc_row_odd" id="l173"> <td class="vc_file_line_number"><a href="#l173">173</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l174"> <td class="vc_file_line_number"><a href="#l174">174</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l175"> <td class="vc_file_line_number"><a href="#l175">175</a></td> <td class="vc_file_line_text"> do {</td> </tr> <tr class="vc_row_odd" id="l176"> <td class="vc_file_line_number"><a href="#l176">176</a></td> <td class="vc_file_line_text"> /* Sentinel value */</td> </tr> <tr class="vc_row_odd" id="l177"> <td class="vc_file_line_number"><a href="#l177">177</a></td> <td class="vc_file_line_text"> apr_size_t blen = 0;</td> </tr> <tr class="vc_row_odd" id="l178"> <td class="vc_file_line_number"><a href="#l178">178</a></td> <td class="vc_file_line_text"> char *start_chunk, *end_chunk, *b;</td> </tr> <tr class="vc_row_odd" id="l179"> <td class="vc_file_line_number"><a href="#l179">179</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l180"> <td class="vc_file_line_number"><a href="#l180">180</a></td> <td class="vc_file_line_text"> /* Always reset the b. */</td> </tr> <tr class="vc_row_odd" id="l181"> <td class="vc_file_line_number"><a href="#l181">181</a></td> <td class="vc_file_line_text"> b = *bp;</td> </tr> <tr class="vc_row_odd" id="l182"> <td class="vc_file_line_number"><a href="#l182">182</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l183"> <td class="vc_file_line_number"><a href="#l183">183</a></td> <td class="vc_file_line_text"> /* Time to read the next chunk size. At this point,</td> </tr> <tr class="vc_row_odd" id="l184"> <td class="vc_file_line_number"><a href="#l184">184</a></td> <td class="vc_file_line_text"> * we should be ready to read a CRLF followed by</td> </tr> <tr class="vc_row_odd" id="l185"> <td class="vc_file_line_number"><a href="#l185">185</a></td> <td class="vc_file_line_text"> * a line that contains the next chunk size.</td> </tr> <tr class="vc_row_odd" id="l186"> <td class="vc_file_line_number"><a href="#l186">186</a></td> <td class="vc_file_line_text"> */</td> </tr> <tr class="vc_row_odd" id="l187"> <td class="vc_file_line_number"><a href="#l187">187</a></td> <td class="vc_file_line_text"> while (!chunk_length)</td> </tr> <tr class="vc_row_odd" id="l188"> <td class="vc_file_line_number"><a href="#l188">188</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l189"> <td class="vc_file_line_number"><a href="#l189">189</a></td> <td class="vc_file_line_text"> /* We are reading the next chunk and see a CRLF. */</td> </tr> <tr class="vc_row_odd" id="l190"> <td class="vc_file_line_number"><a href="#l190">190</a></td> <td class="vc_file_line_text"> if (blen >= 1 && b[0] == '\r') {</td> </tr> <tr class="vc_row_odd" id="l191"> <td class="vc_file_line_number"><a href="#l191">191</a></td> <td class="vc_file_line_text"> b++;</td> </tr> <tr class="vc_row_odd" id="l192"> <td class="vc_file_line_number"><a href="#l192">192</a></td> <td class="vc_file_line_text"> blen--;</td> </tr> <tr class="vc_row_odd" id="l193"> <td class="vc_file_line_number"><a href="#l193">193</a></td> <td class="vc_file_line_text"> if (blen >= 1 && b[0] == '\n') {</td> </tr> <tr class="vc_row_odd" id="l194"> <td class="vc_file_line_number"><a href="#l194">194</a></td> <td class="vc_file_line_text"> b++;</td> </tr> <tr class="vc_row_odd" id="l195"> <td class="vc_file_line_number"><a href="#l195">195</a></td> <td class="vc_file_line_text"> blen--;</td> </tr> <tr class="vc_row_odd" id="l196"> <td class="vc_file_line_number"><a href="#l196">196</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l197"> <td class="vc_file_line_number"><a href="#l197">197</a></td> <td class="vc_file_line_text"> else {</td> </tr> <tr class="vc_row_odd" id="l198"> <td class="vc_file_line_number"><a href="#l198">198</a></td> <td class="vc_file_line_text"> old_length = -1;</td> </tr> <tr class="vc_row_odd" id="l199"> <td class="vc_file_line_number"><a href="#l199">199</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l200"> <td class="vc_file_line_number"><a href="#l200">200</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l201"> <td class="vc_file_line_number"><a href="#l201">201</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l202"> <td class="vc_file_line_number"><a href="#l202">202</a></td> <td class="vc_file_line_text"> /* If blen is 0, we're empty so read more data. */</td> </tr> <tr class="vc_row_odd" id="l203"> <td class="vc_file_line_number"><a href="#l203">203</a></td> <td class="vc_file_line_text"> while (!blen)</td> </tr> <tr class="vc_row_odd" id="l204"> <td class="vc_file_line_number"><a href="#l204">204</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l205"> <td class="vc_file_line_number"><a href="#l205">205</a></td> <td class="vc_file_line_text"> /* Reset and read as much as we can. */</td> </tr> <tr class="vc_row_odd" id="l206"> <td class="vc_file_line_number"><a href="#l206">206</a></td> <td class="vc_file_line_text"> blen = bplen;</td> </tr> <tr class="vc_row_odd" id="l207"> <td class="vc_file_line_number"><a href="#l207">207</a></td> <td class="vc_file_line_text"> b = *bp;</td> </tr> <tr class="vc_row_odd" id="l208"> <td class="vc_file_line_number"><a href="#l208">208</a></td> <td class="vc_file_line_text"> status = ksock_read_socket(sock, b, &blen);</td> </tr> <tr class="vc_row_odd" id="l209"> <td class="vc_file_line_number"><a href="#l209">209</a></td> <td class="vc_file_line_text"> if (status != APR_SUCCESS) {</td> </tr> <tr class="vc_row_odd" id="l210"> <td class="vc_file_line_number"><a href="#l210">210</a></td> <td class="vc_file_line_text"> return status;</td> </tr> <tr class="vc_row_odd" id="l211"> <td class="vc_file_line_number"><a href="#l211">211</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l212"> <td class="vc_file_line_number"><a href="#l212">212</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l213"> <td class="vc_file_line_number"><a href="#l213">213</a></td> <td class="vc_file_line_text"> /* We got caught in the middle of a chunk last time. */ </td> </tr> <tr class="vc_row_odd" id="l214"> <td class="vc_file_line_number"><a href="#l214">214</a></td> <td class="vc_file_line_text"> if (old_length < 0) {</td> </tr> <tr class="vc_row_odd" id="l215"> <td class="vc_file_line_number"><a href="#l215">215</a></td> <td class="vc_file_line_text"> b -= old_length;</td> </tr> <tr class="vc_row_odd" id="l216"> <td class="vc_file_line_number"><a href="#l216">216</a></td> <td class="vc_file_line_text"> blen += old_length;</td> </tr> <tr class="vc_row_odd" id="l217"> <td class="vc_file_line_number"><a href="#l217">217</a></td> <td class="vc_file_line_text"> old_length = 0;</td> </tr> <tr class="vc_row_odd" id="l218"> <td class="vc_file_line_number"><a href="#l218">218</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l219"> <td class="vc_file_line_number"><a href="#l219">219</a></td> <td class="vc_file_line_text"> /* We are reading the next chunk and see a CRLF. */</td> </tr> <tr class="vc_row_odd" id="l220"> <td class="vc_file_line_number"><a href="#l220">220</a></td> <td class="vc_file_line_text"> if (blen >= 2 && b[0] == '\r' && b[1] == '\n') {</td> </tr> <tr class="vc_row_odd" id="l221"> <td class="vc_file_line_number"><a href="#l221">221</a></td> <td class="vc_file_line_text"> b += 2;</td> </tr> <tr class="vc_row_odd" id="l222"> <td class="vc_file_line_number"><a href="#l222">222</a></td> <td class="vc_file_line_text"> blen -= 2;</td> </tr> <tr class="vc_row_odd" id="l223"> <td class="vc_file_line_number"><a href="#l223">223</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l224"> <td class="vc_file_line_number"><a href="#l224">224</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l225"> <td class="vc_file_line_number"><a href="#l225">225</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l226"> <td class="vc_file_line_number"><a href="#l226">226</a></td> <td class="vc_file_line_text"> start_chunk = b;</td> </tr> <tr class="vc_row_odd" id="l227"> <td class="vc_file_line_number"><a href="#l227">227</a></td> <td class="vc_file_line_text"> chunk_length = keepalive_read_chunk_size(start_chunk);</td> </tr> <tr class="vc_row_odd" id="l228"> <td class="vc_file_line_number"><a href="#l228">228</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l229"> <td class="vc_file_line_number"><a href="#l229">229</a></td> <td class="vc_file_line_text"> /* last-chunk */</td> </tr> <tr class="vc_row_odd" id="l230"> <td class="vc_file_line_number"><a href="#l230">230</a></td> <td class="vc_file_line_text"> if (!chunk_length)</td> </tr> <tr class="vc_row_odd" id="l231"> <td class="vc_file_line_number"><a href="#l231">231</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l232"> <td class="vc_file_line_number"><a href="#l232">232</a></td> <td class="vc_file_line_text"> /* See if we already read the trailer and final CRLF */</td> </tr> <tr class="vc_row_odd" id="l233"> <td class="vc_file_line_number"><a href="#l233">233</a></td> <td class="vc_file_line_text"> end_chunk = strstr(b, CRLF CRLF);</td> </tr> <tr class="vc_row_odd" id="l234"> <td class="vc_file_line_number"><a href="#l234">234</a></td> <td class="vc_file_line_text"> if (!end_chunk)</td> </tr> <tr class="vc_row_odd" id="l235"> <td class="vc_file_line_number"><a href="#l235">235</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l236"> <td class="vc_file_line_number"><a href="#l236">236</a></td> <td class="vc_file_line_text"> /* Read as much as we can. */</td> </tr> <tr class="vc_row_odd" id="l237"> <td class="vc_file_line_number"><a href="#l237">237</a></td> <td class="vc_file_line_text"> blen = bplen;</td> </tr> <tr class="vc_row_odd" id="l238"> <td class="vc_file_line_number"><a href="#l238">238</a></td> <td class="vc_file_line_text"> b = *bp;</td> </tr> <tr class="vc_row_odd" id="l239"> <td class="vc_file_line_number"><a href="#l239">239</a></td> <td class="vc_file_line_text"> status = ksock_read_socket(sock, b, &blen);</td> </tr> <tr class="vc_row_odd" id="l240"> <td class="vc_file_line_number"><a href="#l240">240</a></td> <td class="vc_file_line_text"> if (status != APR_SUCCESS)</td> </tr> <tr class="vc_row_odd" id="l241"> <td class="vc_file_line_number"><a href="#l241">241</a></td> <td class="vc_file_line_text"> return status;</td> </tr> <tr class="vc_row_odd" id="l242"> <td class="vc_file_line_number"><a href="#l242">242</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l243"> <td class="vc_file_line_number"><a href="#l243">243</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l244"> <td class="vc_file_line_number"><a href="#l244">244</a></td> <td class="vc_file_line_text"> /* FIXME: If we add pipelining, we need to put</td> </tr> <tr class="vc_row_odd" id="l245"> <td class="vc_file_line_number"><a href="#l245">245</a></td> <td class="vc_file_line_text"> * the remainder back so that it can be read. */</td> </tr> <tr class="vc_row_odd" id="l246"> <td class="vc_file_line_number"><a href="#l246">246</a></td> <td class="vc_file_line_text"> blen -= end_chunk - b + 4;</td> </tr> <tr class="vc_row_odd" id="l247"> <td class="vc_file_line_number"><a href="#l247">247</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l248"> <td class="vc_file_line_number"><a href="#l248">248</a></td> <td class="vc_file_line_text"> return APR_SUCCESS;</td> </tr> <tr class="vc_row_odd" id="l249"> <td class="vc_file_line_number"><a href="#l249">249</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l250"> <td class="vc_file_line_number"><a href="#l250">250</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l251"> <td class="vc_file_line_number"><a href="#l251">251</a></td> <td class="vc_file_line_text"> /* If this fails, we're very unlikely to have read a chunk! */</td> </tr> <tr class="vc_row_odd" id="l252"> <td class="vc_file_line_number"><a href="#l252">252</a></td> <td class="vc_file_line_text"> end_chunk = strstr(start_chunk, CRLF) + 2;</td> </tr> <tr class="vc_row_odd" id="l253"> <td class="vc_file_line_number"><a href="#l253">253</a></td> <td class="vc_file_line_text"> blen -= end_chunk - b;</td> </tr> <tr class="vc_row_odd" id="l254"> <td class="vc_file_line_number"><a href="#l254">254</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l255"> <td class="vc_file_line_number"><a href="#l255">255</a></td> <td class="vc_file_line_text"> /* Oh no, we read more than one chunk this go-around! */</td> </tr> <tr class="vc_row_odd" id="l256"> <td class="vc_file_line_number"><a href="#l256">256</a></td> <td class="vc_file_line_text"> if (chunk_length <= blen) {</td> </tr> <tr class="vc_row_odd" id="l257"> <td class="vc_file_line_number"><a href="#l257">257</a></td> <td class="vc_file_line_text"> b += chunk_length + (end_chunk - b);</td> </tr> <tr class="vc_row_odd" id="l258"> <td class="vc_file_line_number"><a href="#l258">258</a></td> <td class="vc_file_line_text"> blen -= chunk_length;</td> </tr> <tr class="vc_row_odd" id="l259"> <td class="vc_file_line_number"><a href="#l259">259</a></td> <td class="vc_file_line_text"> chunk_length = 0;</td> </tr> <tr class="vc_row_odd" id="l260"> <td class="vc_file_line_number"><a href="#l260">260</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l261"> <td class="vc_file_line_number"><a href="#l261">261</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l262"> <td class="vc_file_line_number"><a href="#l262">262</a></td> <td class="vc_file_line_text"> chunk_length -= blen;</td> </tr> <tr class="vc_row_odd" id="l263"> <td class="vc_file_line_number"><a href="#l263">263</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l264"> <td class="vc_file_line_number"><a href="#l264">264</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l265"> <td class="vc_file_line_number"><a href="#l265">265</a></td> <td class="vc_file_line_text"> if (chunk_length > bplen)</td> </tr> <tr class="vc_row_odd" id="l266"> <td class="vc_file_line_number"><a href="#l266">266</a></td> <td class="vc_file_line_text"> blen = bplen;</td> </tr> <tr class="vc_row_odd" id="l267"> <td class="vc_file_line_number"><a href="#l267">267</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l268"> <td class="vc_file_line_number"><a href="#l268">268</a></td> <td class="vc_file_line_text"> blen = chunk_length;</td> </tr> <tr class="vc_row_odd" id="l269"> <td class="vc_file_line_number"><a href="#l269">269</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l270"> <td class="vc_file_line_number"><a href="#l270">270</a></td> <td class="vc_file_line_text"> status = ksock_read_socket(sock, b, &blen);</td> </tr> <tr class="vc_row_odd" id="l271"> <td class="vc_file_line_number"><a href="#l271">271</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l272"> <td class="vc_file_line_number"><a href="#l272">272</a></td> <td class="vc_file_line_text"> chunk_length -= blen;</td> </tr> <tr class="vc_row_odd" id="l273"> <td class="vc_file_line_number"><a href="#l273">273</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l274"> <td class="vc_file_line_number"><a href="#l274">274</a></td> <td class="vc_file_line_text"> while (status == APR_SUCCESS);</td> </tr> <tr class="vc_row_odd" id="l275"> <td class="vc_file_line_number"><a href="#l275">275</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l276"> <td class="vc_file_line_number"><a href="#l276">276</a></td> <td class="vc_file_line_text"> return APR_SUCCESS;</td> </tr> <tr class="vc_row_odd" id="l277"> <td class="vc_file_line_number"><a href="#l277">277</a></td> <td class="vc_file_line_text">}</td> </tr> <tr class="vc_row_odd" id="l278"> <td class="vc_file_line_number"><a href="#l278">278</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l279"> <td class="vc_file_line_number"><a href="#l279">279</a></td> <td class="vc_file_line_text">static apr_status_t keepalive_load_resp(response_t *resp, </td> </tr> <tr class="vc_row_odd" id="l280"> <td class="vc_file_line_number"><a href="#l280">280</a></td> <td class="vc_file_line_text"> keepalive_socket_t *sock,</td> </tr> <tr class="vc_row_odd" id="l281"> <td class="vc_file_line_number"><a href="#l281">281</a></td> <td class="vc_file_line_text"> apr_size_t remaining, apr_pool_t *pool)</td> </tr> <tr class="vc_row_odd" id="l282"> <td class="vc_file_line_number"><a href="#l282">282</a></td> <td class="vc_file_line_text">{</td> </tr> <tr class="vc_row_odd" id="l283"> <td class="vc_file_line_number"><a href="#l283">283</a></td> <td class="vc_file_line_text"> /* Ugh, we want everything. */</td> </tr> <tr class="vc_row_odd" id="l284"> <td class="vc_file_line_number"><a href="#l284">284</a></td> <td class="vc_file_line_text"> int currentalloc, remain;</td> </tr> <tr class="vc_row_odd" id="l285"> <td class="vc_file_line_number"><a href="#l285">285</a></td> <td class="vc_file_line_text"> apr_size_t i;</td> </tr> <tr class="vc_row_odd" id="l286"> <td class="vc_file_line_number"><a href="#l286">286</a></td> <td class="vc_file_line_text"> char *cp, *op, b[MAX_DOC_LENGTH];</td> </tr> <tr class="vc_row_odd" id="l287"> <td class="vc_file_line_number"><a href="#l287">287</a></td> <td class="vc_file_line_text"> apr_status_t status;</td> </tr> <tr class="vc_row_odd" id="l288"> <td class="vc_file_line_number"><a href="#l288">288</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l289"> <td class="vc_file_line_number"><a href="#l289">289</a></td> <td class="vc_file_line_text"> if (remaining > 0)</td> </tr> <tr class="vc_row_odd" id="l290"> <td class="vc_file_line_number"><a href="#l290">290</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l291"> <td class="vc_file_line_number"><a href="#l291">291</a></td> <td class="vc_file_line_text"> remain = 1;</td> </tr> <tr class="vc_row_odd" id="l292"> <td class="vc_file_line_number"><a href="#l292">292</a></td> <td class="vc_file_line_text"> currentalloc = remaining + resp->rbufsize;</td> </tr> <tr class="vc_row_odd" id="l293"> <td class="vc_file_line_number"><a href="#l293">293</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l294"> <td class="vc_file_line_number"><a href="#l294">294</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l295"> <td class="vc_file_line_number"><a href="#l295">295</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l296"> <td class="vc_file_line_number"><a href="#l296">296</a></td> <td class="vc_file_line_text"> remain = 0;</td> </tr> <tr class="vc_row_odd" id="l297"> <td class="vc_file_line_number"><a href="#l297">297</a></td> <td class="vc_file_line_text"> currentalloc = MAX_DOC_LENGTH + resp->rbufsize;</td> </tr> <tr class="vc_row_odd" id="l298"> <td class="vc_file_line_number"><a href="#l298">298</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l299"> <td class="vc_file_line_number"><a href="#l299">299</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l300"> <td class="vc_file_line_number"><a href="#l300">300</a></td> <td class="vc_file_line_text"> cp = apr_palloc(pool, currentalloc);</td> </tr> <tr class="vc_row_odd" id="l301"> <td class="vc_file_line_number"><a href="#l301">301</a></td> <td class="vc_file_line_text"> memcpy(cp, resp->rbuf, resp->rbufsize);</td> </tr> <tr class="vc_row_odd" id="l302"> <td class="vc_file_line_number"><a href="#l302">302</a></td> <td class="vc_file_line_text"> resp->rbuf = cp;</td> </tr> <tr class="vc_row_odd" id="l303"> <td class="vc_file_line_number"><a href="#l303">303</a></td> <td class="vc_file_line_text"> cp = resp->rbuf + resp->rbufsize;</td> </tr> <tr class="vc_row_odd" id="l304"> <td class="vc_file_line_number"><a href="#l304">304</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l305"> <td class="vc_file_line_number"><a href="#l305">305</a></td> <td class="vc_file_line_text"> do</td> </tr> <tr class="vc_row_odd" id="l306"> <td class="vc_file_line_number"><a href="#l306">306</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l307"> <td class="vc_file_line_number"><a href="#l307">307</a></td> <td class="vc_file_line_text"> if (!remain)</td> </tr> <tr class="vc_row_odd" id="l308"> <td class="vc_file_line_number"><a href="#l308">308</a></td> <td class="vc_file_line_text"> i = MAX_DOC_LENGTH - 1;</td> </tr> <tr class="vc_row_odd" id="l309"> <td class="vc_file_line_number"><a href="#l309">309</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l310"> <td class="vc_file_line_number"><a href="#l310">310</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l311"> <td class="vc_file_line_number"><a href="#l311">311</a></td> <td class="vc_file_line_text"> if (remaining > MAX_DOC_LENGTH - 1)</td> </tr> <tr class="vc_row_odd" id="l312"> <td class="vc_file_line_number"><a href="#l312">312</a></td> <td class="vc_file_line_text"> i = MAX_DOC_LENGTH - 1;</td> </tr> <tr class="vc_row_odd" id="l313"> <td class="vc_file_line_number"><a href="#l313">313</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l314"> <td class="vc_file_line_number"><a href="#l314">314</a></td> <td class="vc_file_line_text"> i = remaining;</td> </tr> <tr class="vc_row_odd" id="l315"> <td class="vc_file_line_number"><a href="#l315">315</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l316"> <td class="vc_file_line_number"><a href="#l316">316</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l317"> <td class="vc_file_line_number"><a href="#l317">317</a></td> <td class="vc_file_line_text"> status = ksock_read_socket(sock, b, &i);</td> </tr> <tr class="vc_row_odd" id="l318"> <td class="vc_file_line_number"><a href="#l318">318</a></td> <td class="vc_file_line_text"> if (resp->rbufsize + i > currentalloc)</td> </tr> <tr class="vc_row_odd" id="l319"> <td class="vc_file_line_number"><a href="#l319">319</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l320"> <td class="vc_file_line_number"><a href="#l320">320</a></td> <td class="vc_file_line_text"> /* You can think why this always work. */</td> </tr> <tr class="vc_row_odd" id="l321"> <td class="vc_file_line_number"><a href="#l321">321</a></td> <td class="vc_file_line_text"> currentalloc *= 2;</td> </tr> <tr class="vc_row_odd" id="l322"> <td class="vc_file_line_number"><a href="#l322">322</a></td> <td class="vc_file_line_text"> op = resp->rbuf;</td> </tr> <tr class="vc_row_odd" id="l323"> <td class="vc_file_line_number"><a href="#l323">323</a></td> <td class="vc_file_line_text"> resp->rbuf = apr_palloc(pool, currentalloc);</td> </tr> <tr class="vc_row_odd" id="l324"> <td class="vc_file_line_number"><a href="#l324">324</a></td> <td class="vc_file_line_text"> memcpy(resp->rbuf, op, cp - op);</td> </tr> <tr class="vc_row_odd" id="l325"> <td class="vc_file_line_number"><a href="#l325">325</a></td> <td class="vc_file_line_text"> cp = resp->rbuf + (cp - op);</td> </tr> <tr class="vc_row_odd" id="l326"> <td class="vc_file_line_number"><a href="#l326">326</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l327"> <td class="vc_file_line_number"><a href="#l327">327</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l328"> <td class="vc_file_line_number"><a href="#l328">328</a></td> <td class="vc_file_line_text"> memcpy(cp, b, i);</td> </tr> <tr class="vc_row_odd" id="l329"> <td class="vc_file_line_number"><a href="#l329">329</a></td> <td class="vc_file_line_text"> resp->rbufsize += i;</td> </tr> <tr class="vc_row_odd" id="l330"> <td class="vc_file_line_number"><a href="#l330">330</a></td> <td class="vc_file_line_text"> cp += i;</td> </tr> <tr class="vc_row_odd" id="l331"> <td class="vc_file_line_number"><a href="#l331">331</a></td> <td class="vc_file_line_text"> remaining -= i;</td> </tr> <tr class="vc_row_odd" id="l332"> <td class="vc_file_line_number"><a href="#l332">332</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l333"> <td class="vc_file_line_number"><a href="#l333">333</a></td> <td class="vc_file_line_text"> while (status != APR_EGENERAL && status != APR_EOF && </td> </tr> <tr class="vc_row_odd" id="l334"> <td class="vc_file_line_number"><a href="#l334">334</a></td> <td class="vc_file_line_text"> status != APR_TIMEUP && (!remain || remaining));</td> </tr> <tr class="vc_row_odd" id="l335"> <td class="vc_file_line_number"><a href="#l335">335</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l336"> <td class="vc_file_line_number"><a href="#l336">336</a></td> <td class="vc_file_line_text"> return status;</td> </tr> <tr class="vc_row_odd" id="l337"> <td class="vc_file_line_number"><a href="#l337">337</a></td> <td class="vc_file_line_text">}</td> </tr> <tr class="vc_row_odd" id="l338"> <td class="vc_file_line_number"><a href="#l338">338</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l339"> <td class="vc_file_line_number"><a href="#l339">339</a></td> <td class="vc_file_line_text">/**</td> </tr> <tr class="vc_row_odd" id="l340"> <td class="vc_file_line_number"><a href="#l340">340</a></td> <td class="vc_file_line_text"> * Keep-alive implementation for recv_resp.</td> </tr> <tr class="vc_row_odd" id="l341"> <td class="vc_file_line_number"><a href="#l341">341</a></td> <td class="vc_file_line_text"> */</td> </tr> <tr class="vc_row_odd" id="l342"> <td class="vc_file_line_number"><a href="#l342">342</a></td> <td class="vc_file_line_text">apr_status_t keepalive_recv_resp(response_t **resp, socket_t *sock, apr_pool_t *pool)</td> </tr> <tr class="vc_row_odd" id="l343"> <td class="vc_file_line_number"><a href="#l343">343</a></td> <td class="vc_file_line_text">{</td> </tr> <tr class="vc_row_odd" id="l344"> <td class="vc_file_line_number"><a href="#l344">344</a></td> <td class="vc_file_line_text"> keepalive_socket_t *ksock = (keepalive_socket_t *)sock;</td> </tr> <tr class="vc_row_odd" id="l345"> <td class="vc_file_line_number"><a href="#l345">345</a></td> <td class="vc_file_line_text"> char *cl, *ecl, cls[17];</td> </tr> <tr class="vc_row_odd" id="l346"> <td class="vc_file_line_number"><a href="#l346">346</a></td> <td class="vc_file_line_text"> char *current_line;</td> </tr> <tr class="vc_row_odd" id="l347"> <td class="vc_file_line_number"><a href="#l347">347</a></td> <td class="vc_file_line_text"> apr_size_t i;</td> </tr> <tr class="vc_row_odd" id="l348"> <td class="vc_file_line_number"><a href="#l348">348</a></td> <td class="vc_file_line_text"> response_t *new_resp;</td> </tr> <tr class="vc_row_odd" id="l349"> <td class="vc_file_line_number"><a href="#l349">349</a></td> <td class="vc_file_line_text"> apr_status_t status;</td> </tr> <tr class="vc_row_odd" id="l350"> <td class="vc_file_line_number"><a href="#l350">350</a></td> <td class="vc_file_line_text"> long content_length = 0, chunk_length;</td> </tr> <tr class="vc_row_odd" id="l351"> <td class="vc_file_line_number"><a href="#l351">351</a></td> <td class="vc_file_line_text"> const char *header;</td> </tr> <tr class="vc_row_odd" id="l352"> <td class="vc_file_line_number"><a href="#l352">352</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l353"> <td class="vc_file_line_number"><a href="#l353">353</a></td> <td class="vc_file_line_text"> new_resp = apr_pcalloc(pool, sizeof(response_t));</td> </tr> <tr class="vc_row_odd" id="l354"> <td class="vc_file_line_number"><a href="#l354">354</a></td> <td class="vc_file_line_text"> new_resp->rbuftype = POOL;</td> </tr> <tr class="vc_row_odd" id="l355"> <td class="vc_file_line_number"><a href="#l355">355</a></td> <td class="vc_file_line_text"> new_resp->rbufsize = MAX_DOC_LENGTH - 1;</td> </tr> <tr class="vc_row_odd" id="l356"> <td class="vc_file_line_number"><a href="#l356">356</a></td> <td class="vc_file_line_text"> new_resp->rbuf = apr_palloc(pool, new_resp->rbufsize);</td> </tr> <tr class="vc_row_odd" id="l357"> <td class="vc_file_line_number"><a href="#l357">357</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l358"> <td class="vc_file_line_number"><a href="#l358">358</a></td> <td class="vc_file_line_text"> status = ksock_read_socket(ksock, new_resp->rbuf, &new_resp->rbufsize);</td> </tr> <tr class="vc_row_odd" id="l359"> <td class="vc_file_line_number"><a href="#l359">359</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l360"> <td class="vc_file_line_number"><a href="#l360">360</a></td> <td class="vc_file_line_text"> if (status != APR_SUCCESS && status != APR_EOF) {</td> </tr> <tr class="vc_row_odd" id="l361"> <td class="vc_file_line_number"><a href="#l361">361</a></td> <td class="vc_file_line_text"> return status;</td> </tr> <tr class="vc_row_odd" id="l362"> <td class="vc_file_line_number"><a href="#l362">362</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l363"> <td class="vc_file_line_number"><a href="#l363">363</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l364"> <td class="vc_file_line_number"><a href="#l364">364</a></td> <td class="vc_file_line_text"> /* FIXME: Assume we got the full header for now. */</td> </tr> <tr class="vc_row_odd" id="l365"> <td class="vc_file_line_number"><a href="#l365">365</a></td> <td class="vc_file_line_text"> new_resp->headers = apr_table_make(pool, 25);</td> </tr> <tr class="vc_row_odd" id="l366"> <td class="vc_file_line_number"><a href="#l366">366</a></td> <td class="vc_file_line_text"> current_line = new_resp->rbuf;</td> </tr> <tr class="vc_row_odd" id="l367"> <td class="vc_file_line_number"><a href="#l367">367</a></td> <td class="vc_file_line_text"> do {</td> </tr> <tr class="vc_row_odd" id="l368"> <td class="vc_file_line_number"><a href="#l368">368</a></td> <td class="vc_file_line_text"> char *end_of_line, *header_end, *header_key, *header_val;</td> </tr> <tr class="vc_row_odd" id="l369"> <td class="vc_file_line_number"><a href="#l369">369</a></td> <td class="vc_file_line_text"> int line_length, key_length;</td> </tr> <tr class="vc_row_odd" id="l370"> <td class="vc_file_line_number"><a href="#l370">370</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l371"> <td class="vc_file_line_number"><a href="#l371">371</a></td> <td class="vc_file_line_text"> end_of_line = strstr(current_line, CRLF);</td> </tr> <tr class="vc_row_odd" id="l372"> <td class="vc_file_line_number"><a href="#l372">372</a></td> <td class="vc_file_line_text"> if (!end_of_line || end_of_line == current_line) {</td> </tr> <tr class="vc_row_odd" id="l373"> <td class="vc_file_line_number"><a href="#l373">373</a></td> <td class="vc_file_line_text"> break;</td> </tr> <tr class="vc_row_odd" id="l374"> <td class="vc_file_line_number"><a href="#l374">374</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l375"> <td class="vc_file_line_number"><a href="#l375">375</a></td> <td class="vc_file_line_text"> line_length = end_of_line - current_line;</td> </tr> <tr class="vc_row_odd" id="l376"> <td class="vc_file_line_number"><a href="#l376">376</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l377"> <td class="vc_file_line_number"><a href="#l377">377</a></td> <td class="vc_file_line_text"> header_end = memchr(current_line, ':', line_length);</td> </tr> <tr class="vc_row_odd" id="l378"> <td class="vc_file_line_number"><a href="#l378">378</a></td> <td class="vc_file_line_text"> if (header_end) {</td> </tr> <tr class="vc_row_odd" id="l379"> <td class="vc_file_line_number"><a href="#l379">379</a></td> <td class="vc_file_line_text"> key_length = header_end - current_line;</td> </tr> <tr class="vc_row_odd" id="l380"> <td class="vc_file_line_number"><a href="#l380">380</a></td> <td class="vc_file_line_text"> </td> </tr> <tr class="vc_row_odd" id="l381"> <td class="vc_file_line_number"><a href="#l381">381</a></td> <td class="vc_file_line_text"> header_key = apr_pstrmemdup(pool, current_line, key_length);</td> </tr> <tr class="vc_row_odd" id="l382"> <td class="vc_file_line_number"><a href="#l382">382</a></td> <td class="vc_file_line_text"> header_val = apr_pstrmemdup(pool, current_line + key_length + 2,</td> </tr> <tr class="vc_row_odd" id="l383"> <td class="vc_file_line_number"><a href="#l383">383</a></td> <td class="vc_file_line_text"> line_length - key_length - 2);</td> </tr> <tr class="vc_row_odd" id="l384"> <td class="vc_file_line_number"><a href="#l384">384</a></td> <td class="vc_file_line_text"> apr_table_set(new_resp->headers, header_key, header_val);</td> </tr> <tr class="vc_row_odd" id="l385"> <td class="vc_file_line_number"><a href="#l385">385</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l386"> <td class="vc_file_line_number"><a href="#l386">386</a></td> <td class="vc_file_line_text"> current_line += line_length + sizeof(CRLF) - 1;</td> </tr> <tr class="vc_row_odd" id="l387"> <td class="vc_file_line_number"><a href="#l387">387</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l388"> <td class="vc_file_line_number"><a href="#l388">388</a></td> <td class="vc_file_line_text"> while((current_line - new_resp->rbuf) < new_resp->rbufsize);</td> </tr> <tr class="vc_row_odd" id="l389"> <td class="vc_file_line_number"><a href="#l389">389</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l390"> <td class="vc_file_line_number"><a href="#l390">390</a></td> <td class="vc_file_line_text"> /* If this exists, we aren't keepalive anymore. */</td> </tr> <tr class="vc_row_odd" id="l391"> <td class="vc_file_line_number"><a href="#l391">391</a></td> <td class="vc_file_line_text"> header = apr_table_get(new_resp->headers, "Connection");</td> </tr> <tr class="vc_row_odd" id="l392"> <td class="vc_file_line_number"><a href="#l392">392</a></td> <td class="vc_file_line_text"> if (header && !strcasecmp(header, "Close")) {</td> </tr> <tr class="vc_row_odd" id="l393"> <td class="vc_file_line_number"><a href="#l393">393</a></td> <td class="vc_file_line_text"> new_resp->keepalive = 0; </td> </tr> <tr class="vc_row_odd" id="l394"> <td class="vc_file_line_number"><a href="#l394">394</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l395"> <td class="vc_file_line_number"><a href="#l395">395</a></td> <td class="vc_file_line_text"> else {</td> </tr> <tr class="vc_row_odd" id="l396"> <td class="vc_file_line_number"><a href="#l396">396</a></td> <td class="vc_file_line_text"> new_resp->keepalive = 1; </td> </tr> <tr class="vc_row_odd" id="l397"> <td class="vc_file_line_number"><a href="#l397">397</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l398"> <td class="vc_file_line_number"><a href="#l398">398</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l399"> <td class="vc_file_line_number"><a href="#l399">399</a></td> <td class="vc_file_line_text"> /* If we have a HEAD request, we shouldn't be receiving a body. */</td> </tr> <tr class="vc_row_odd" id="l400"> <td class="vc_file_line_number"><a href="#l400">400</a></td> <td class="vc_file_line_text"> if (ksock->method == HEAD) {</td> </tr> <tr class="vc_row_odd" id="l401"> <td class="vc_file_line_number"><a href="#l401">401</a></td> <td class="vc_file_line_text"> *resp = new_resp;</td> </tr> <tr class="vc_row_odd" id="l402"> <td class="vc_file_line_number"><a href="#l402">402</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l403"> <td class="vc_file_line_number"><a href="#l403">403</a></td> <td class="vc_file_line_text"> return APR_SUCCESS;</td> </tr> <tr class="vc_row_odd" id="l404"> <td class="vc_file_line_number"><a href="#l404">404</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l405"> <td class="vc_file_line_number"><a href="#l405">405</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l406"> <td class="vc_file_line_number"><a href="#l406">406</a></td> <td class="vc_file_line_text"> header = apr_table_get(new_resp->headers, "Transfer-Encoding");</td> </tr> <tr class="vc_row_odd" id="l407"> <td class="vc_file_line_number"><a href="#l407">407</a></td> <td class="vc_file_line_text"> if (header && !strcasecmp(header, "Chunked"))</td> </tr> <tr class="vc_row_odd" id="l408"> <td class="vc_file_line_number"><a href="#l408">408</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l409"> <td class="vc_file_line_number"><a href="#l409">409</a></td> <td class="vc_file_line_text"> new_resp->chunked = 1;</td> </tr> <tr class="vc_row_odd" id="l410"> <td class="vc_file_line_number"><a href="#l410">410</a></td> <td class="vc_file_line_text"> new_resp->chunk = NULL;</td> </tr> <tr class="vc_row_odd" id="l411"> <td class="vc_file_line_number"><a href="#l411">411</a></td> <td class="vc_file_line_text"> chunk_length = 0;</td> </tr> <tr class="vc_row_odd" id="l412"> <td class="vc_file_line_number"><a href="#l412">412</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l413"> <td class="vc_file_line_number"><a href="#l413">413</a></td> <td class="vc_file_line_text"> /* Find where headers ended */</td> </tr> <tr class="vc_row_odd" id="l414"> <td class="vc_file_line_number"><a href="#l414">414</a></td> <td class="vc_file_line_text"> cl = current_line;</td> </tr> <tr class="vc_row_odd" id="l415"> <td class="vc_file_line_number"><a href="#l415">415</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l416"> <td class="vc_file_line_number"><a href="#l416">416</a></td> <td class="vc_file_line_text"> if (cl) {</td> </tr> <tr class="vc_row_odd" id="l417"> <td class="vc_file_line_number"><a href="#l417">417</a></td> <td class="vc_file_line_text"> /* Skip over the CRLF chars */</td> </tr> <tr class="vc_row_odd" id="l418"> <td class="vc_file_line_number"><a href="#l418">418</a></td> <td class="vc_file_line_text"> cl += sizeof(CRLF)-1;</td> </tr> <tr class="vc_row_odd" id="l419"> <td class="vc_file_line_number"><a href="#l419">419</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l420"> <td class="vc_file_line_number"><a href="#l420">420</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l421"> <td class="vc_file_line_number"><a href="#l421">421</a></td> <td class="vc_file_line_text"> /* We have a partial chunk and we aren't at the end. */</td> </tr> <tr class="vc_row_odd" id="l422"> <td class="vc_file_line_number"><a href="#l422">422</a></td> <td class="vc_file_line_text"> if (cl && *cl && (cl - (char*)new_resp->rbuf) < new_resp->rbufsize) {</td> </tr> <tr class="vc_row_odd" id="l423"> <td class="vc_file_line_number"><a href="#l423">423</a></td> <td class="vc_file_line_text"> int remaining;</td> </tr> <tr class="vc_row_odd" id="l424"> <td class="vc_file_line_number"><a href="#l424">424</a></td> <td class="vc_file_line_text"> </td> </tr> <tr class="vc_row_odd" id="l425"> <td class="vc_file_line_number"><a href="#l425">425</a></td> <td class="vc_file_line_text"> do {</td> </tr> <tr class="vc_row_odd" id="l426"> <td class="vc_file_line_number"><a href="#l426">426</a></td> <td class="vc_file_line_text"> if (new_resp->chunk) {</td> </tr> <tr class="vc_row_odd" id="l427"> <td class="vc_file_line_number"><a href="#l427">427</a></td> <td class="vc_file_line_text"> /* If we have enough space to skip over the ending CRLF,</td> </tr> <tr class="vc_row_odd" id="l428"> <td class="vc_file_line_number"><a href="#l428">428</a></td> <td class="vc_file_line_text"> * do so. */</td> </tr> <tr class="vc_row_odd" id="l429"> <td class="vc_file_line_number"><a href="#l429">429</a></td> <td class="vc_file_line_text"> if (chunk_length + 2 <= remaining) {</td> </tr> <tr class="vc_row_odd" id="l430"> <td class="vc_file_line_number"><a href="#l430">430</a></td> <td class="vc_file_line_text"> new_resp->chunk += chunk_length + 2;</td> </tr> <tr class="vc_row_odd" id="l431"> <td class="vc_file_line_number"><a href="#l431">431</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l432"> <td class="vc_file_line_number"><a href="#l432">432</a></td> <td class="vc_file_line_text"> else {</td> </tr> <tr class="vc_row_odd" id="l433"> <td class="vc_file_line_number"><a href="#l433">433</a></td> <td class="vc_file_line_text"> /* We got more than a chunk, but not the full CRLF. */</td> </tr> <tr class="vc_row_odd" id="l434"> <td class="vc_file_line_number"><a href="#l434">434</a></td> <td class="vc_file_line_text"> chunk_length = -(remaining - chunk_length);</td> </tr> <tr class="vc_row_odd" id="l435"> <td class="vc_file_line_number"><a href="#l435">435</a></td> <td class="vc_file_line_text"> remaining = 0;</td> </tr> <tr class="vc_row_odd" id="l436"> <td class="vc_file_line_number"><a href="#l436">436</a></td> <td class="vc_file_line_text"> break;</td> </tr> <tr class="vc_row_odd" id="l437"> <td class="vc_file_line_number"><a href="#l437">437</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l438"> <td class="vc_file_line_number"><a href="#l438">438</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l439"> <td class="vc_file_line_number"><a href="#l439">439</a></td> <td class="vc_file_line_text"> else {</td> </tr> <tr class="vc_row_odd" id="l440"> <td class="vc_file_line_number"><a href="#l440">440</a></td> <td class="vc_file_line_text"> new_resp->chunk = cl;</td> </tr> <tr class="vc_row_odd" id="l441"> <td class="vc_file_line_number"><a href="#l441">441</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l442"> <td class="vc_file_line_number"><a href="#l442">442</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l443"> <td class="vc_file_line_number"><a href="#l443">443</a></td> <td class="vc_file_line_text"> if ((new_resp->chunk - (char*)new_resp->rbuf) <</td> </tr> <tr class="vc_row_odd" id="l444"> <td class="vc_file_line_number"><a href="#l444">444</a></td> <td class="vc_file_line_text"> new_resp->rbufsize && *new_resp->chunk) {</td> </tr> <tr class="vc_row_odd" id="l445"> <td class="vc_file_line_number"><a href="#l445">445</a></td> <td class="vc_file_line_text"> char *foo;</td> </tr> <tr class="vc_row_odd" id="l446"> <td class="vc_file_line_number"><a href="#l446">446</a></td> <td class="vc_file_line_text"> chunk_length = keepalive_read_chunk_size(new_resp->chunk);</td> </tr> <tr class="vc_row_odd" id="l447"> <td class="vc_file_line_number"><a href="#l447">447</a></td> <td class="vc_file_line_text"> /* Search for the beginning of the chunk. */</td> </tr> <tr class="vc_row_odd" id="l448"> <td class="vc_file_line_number"><a href="#l448">448</a></td> <td class="vc_file_line_text"> foo = strstr(new_resp->chunk, CRLF);</td> </tr> <tr class="vc_row_odd" id="l449"> <td class="vc_file_line_number"><a href="#l449">449</a></td> <td class="vc_file_line_text"> assert(foo);</td> </tr> <tr class="vc_row_odd" id="l450"> <td class="vc_file_line_number"><a href="#l450">450</a></td> <td class="vc_file_line_text"> new_resp->chunk = foo + 2;</td> </tr> <tr class="vc_row_odd" id="l451"> <td class="vc_file_line_number"><a href="#l451">451</a></td> <td class="vc_file_line_text"> remaining = new_resp->rbufsize - </td> </tr> <tr class="vc_row_odd" id="l452"> <td class="vc_file_line_number"><a href="#l452">452</a></td> <td class="vc_file_line_text"> (int)(new_resp->chunk - </td> </tr> <tr class="vc_row_odd" id="l453"> <td class="vc_file_line_number"><a href="#l453">453</a></td> <td class="vc_file_line_text"> (char*)new_resp->rbuf);</td> </tr> <tr class="vc_row_odd" id="l454"> <td class="vc_file_line_number"><a href="#l454">454</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l455"> <td class="vc_file_line_number"><a href="#l455">455</a></td> <td class="vc_file_line_text"> else {</td> </tr> <tr class="vc_row_odd" id="l456"> <td class="vc_file_line_number"><a href="#l456">456</a></td> <td class="vc_file_line_text"> new_resp->chunk = NULL;</td> </tr> <tr class="vc_row_odd" id="l457"> <td class="vc_file_line_number"><a href="#l457">457</a></td> <td class="vc_file_line_text"> remaining = 0;</td> </tr> <tr class="vc_row_odd" id="l458"> <td class="vc_file_line_number"><a href="#l458">458</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l459"> <td class="vc_file_line_number"><a href="#l459">459</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l460"> <td class="vc_file_line_number"><a href="#l460">460</a></td> <td class="vc_file_line_text"> while (remaining > chunk_length);</td> </tr> <tr class="vc_row_odd" id="l461"> <td class="vc_file_line_number"><a href="#l461">461</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l462"> <td class="vc_file_line_number"><a href="#l462">462</a></td> <td class="vc_file_line_text"> chunk_length -= remaining;</td> </tr> <tr class="vc_row_odd" id="l463"> <td class="vc_file_line_number"><a href="#l463">463</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l464"> <td class="vc_file_line_number"><a href="#l464">464</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l465"> <td class="vc_file_line_number"><a href="#l465">465</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l466"> <td class="vc_file_line_number"><a href="#l466">466</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l467"> <td class="vc_file_line_number"><a href="#l467">467</a></td> <td class="vc_file_line_text"> header = apr_table_get(new_resp->headers, "Content-Length");</td> </tr> <tr class="vc_row_odd" id="l468"> <td class="vc_file_line_number"><a href="#l468">468</a></td> <td class="vc_file_line_text"> if (!header)</td> </tr> <tr class="vc_row_odd" id="l469"> <td class="vc_file_line_number"><a href="#l469">469</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l470"> <td class="vc_file_line_number"><a href="#l470">470</a></td> <td class="vc_file_line_text"> new_resp->keepalive = 0; </td> </tr> <tr class="vc_row_odd" id="l471"> <td class="vc_file_line_number"><a href="#l471">471</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l472"> <td class="vc_file_line_number"><a href="#l472">472</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l473"> <td class="vc_file_line_number"><a href="#l473">473</a></td> <td class="vc_file_line_text"> if (header)</td> </tr> <tr class="vc_row_odd" id="l474"> <td class="vc_file_line_number"><a href="#l474">474</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l475"> <td class="vc_file_line_number"><a href="#l475">475</a></td> <td class="vc_file_line_text"> cl = (char*)header;</td> </tr> <tr class="vc_row_odd" id="l476"> <td class="vc_file_line_number"><a href="#l476">476</a></td> <td class="vc_file_line_text"> ecl = cl + strlen(cl);</td> </tr> <tr class="vc_row_odd" id="l477"> <td class="vc_file_line_number"><a href="#l477">477</a></td> <td class="vc_file_line_text"> if (ecl && ecl - cl < 16)</td> </tr> <tr class="vc_row_odd" id="l478"> <td class="vc_file_line_number"><a href="#l478">478</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l479"> <td class="vc_file_line_number"><a href="#l479">479</a></td> <td class="vc_file_line_text"> strncpy(cls, cl, ecl - cl);</td> </tr> <tr class="vc_row_odd" id="l480"> <td class="vc_file_line_number"><a href="#l480">480</a></td> <td class="vc_file_line_text"> cls[ecl-cl] = '\0';</td> </tr> <tr class="vc_row_odd" id="l481"> <td class="vc_file_line_number"><a href="#l481">481</a></td> <td class="vc_file_line_text"> content_length = strtol(cls, &ecl, 10);</td> </tr> <tr class="vc_row_odd" id="l482"> <td class="vc_file_line_number"><a href="#l482">482</a></td> <td class="vc_file_line_text"> if (*ecl != '\0')</td> </tr> <tr class="vc_row_odd" id="l483"> <td class="vc_file_line_number"><a href="#l483">483</a></td> <td class="vc_file_line_text"> new_resp->keepalive = 0; </td> </tr> <tr class="vc_row_odd" id="l484"> <td class="vc_file_line_number"><a href="#l484">484</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l485"> <td class="vc_file_line_number"><a href="#l485">485</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l486"> <td class="vc_file_line_number"><a href="#l486">486</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l487"> <td class="vc_file_line_number"><a href="#l487">487</a></td> <td class="vc_file_line_text"> if (new_resp->keepalive)</td> </tr> <tr class="vc_row_odd" id="l488"> <td class="vc_file_line_number"><a href="#l488">488</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l489"> <td class="vc_file_line_number"><a href="#l489">489</a></td> <td class="vc_file_line_text"> /* Find where we ended */</td> </tr> <tr class="vc_row_odd" id="l490"> <td class="vc_file_line_number"><a href="#l490">490</a></td> <td class="vc_file_line_text"> ecl = current_line;</td> </tr> <tr class="vc_row_odd" id="l491"> <td class="vc_file_line_number"><a href="#l491">491</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l492"> <td class="vc_file_line_number"><a href="#l492">492</a></td> <td class="vc_file_line_text"> /* We didn't get full headers. Crap. */</td> </tr> <tr class="vc_row_odd" id="l493"> <td class="vc_file_line_number"><a href="#l493">493</a></td> <td class="vc_file_line_text"> if (!ecl)</td> </tr> <tr class="vc_row_odd" id="l494"> <td class="vc_file_line_number"><a href="#l494">494</a></td> <td class="vc_file_line_text"> new_resp->keepalive = 0; </td> </tr> <tr class="vc_row_odd" id="l495"> <td class="vc_file_line_number"><a href="#l495">495</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l496"> <td class="vc_file_line_number"><a href="#l496">496</a></td> <td class="vc_file_line_text"> ecl += sizeof(CRLF) - 1;</td> </tr> <tr class="vc_row_odd" id="l497"> <td class="vc_file_line_number"><a href="#l497">497</a></td> <td class="vc_file_line_text"> content_length -= new_resp->rbufsize - (ecl - (char*)new_resp->rbuf);</td> </tr> <tr class="vc_row_odd" id="l498"> <td class="vc_file_line_number"><a href="#l498">498</a></td> <td class="vc_file_line_text"> } </td> </tr> <tr class="vc_row_odd" id="l499"> <td class="vc_file_line_number"><a href="#l499">499</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l500"> <td class="vc_file_line_number"><a href="#l500">500</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l501"> <td class="vc_file_line_number"><a href="#l501">501</a></td> <td class="vc_file_line_text"> </td> </tr> <tr class="vc_row_odd" id="l502"> <td class="vc_file_line_number"><a href="#l502">502</a></td> <td class="vc_file_line_text"> if (ksock->wantresponse)</td> </tr> <tr class="vc_row_odd" id="l503"> <td class="vc_file_line_number"><a href="#l503">503</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l504"> <td class="vc_file_line_number"><a href="#l504">504</a></td> <td class="vc_file_line_text"> if (new_resp->keepalive)</td> </tr> <tr class="vc_row_odd" id="l505"> <td class="vc_file_line_number"><a href="#l505">505</a></td> <td class="vc_file_line_text"> status = keepalive_load_resp(new_resp, ksock, content_length, pool);</td> </tr> <tr class="vc_row_odd" id="l506"> <td class="vc_file_line_number"><a href="#l506">506</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l507"> <td class="vc_file_line_number"><a href="#l507">507</a></td> <td class="vc_file_line_text"> status = keepalive_load_resp(new_resp, ksock, 0, pool);</td> </tr> <tr class="vc_row_odd" id="l508"> <td class="vc_file_line_number"><a href="#l508">508</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l509"> <td class="vc_file_line_number"><a href="#l509">509</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l510"> <td class="vc_file_line_number"><a href="#l510">510</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l511"> <td class="vc_file_line_number"><a href="#l511">511</a></td> <td class="vc_file_line_text"> char *b = apr_palloc(pool, MAX_DOC_LENGTH);</td> </tr> <tr class="vc_row_odd" id="l512"> <td class="vc_file_line_number"><a href="#l512">512</a></td> <td class="vc_file_line_text"> if (new_resp->chunked)</td> </tr> <tr class="vc_row_odd" id="l513"> <td class="vc_file_line_number"><a href="#l513">513</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l514"> <td class="vc_file_line_number"><a href="#l514">514</a></td> <td class="vc_file_line_text"> status = keepalive_read_chunk(new_resp, ksock, chunk_length,</td> </tr> <tr class="vc_row_odd" id="l515"> <td class="vc_file_line_number"><a href="#l515">515</a></td> <td class="vc_file_line_text"> &b, MAX_DOC_LENGTH - 1);</td> </tr> <tr class="vc_row_odd" id="l516"> <td class="vc_file_line_number"><a href="#l516">516</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l517"> <td class="vc_file_line_number"><a href="#l517">517</a></td> <td class="vc_file_line_text"> else if (new_resp->keepalive)</td> </tr> <tr class="vc_row_odd" id="l518"> <td class="vc_file_line_number"><a href="#l518">518</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l519"> <td class="vc_file_line_number"><a href="#l519">519</a></td> <td class="vc_file_line_text"> while (content_length && status != APR_EGENERAL &&</td> </tr> <tr class="vc_row_odd" id="l520"> <td class="vc_file_line_number"><a href="#l520">520</a></td> <td class="vc_file_line_text"> status != APR_EOF && status != APR_TIMEUP) {</td> </tr> <tr class="vc_row_odd" id="l521"> <td class="vc_file_line_number"><a href="#l521">521</a></td> <td class="vc_file_line_text"> if (content_length > MAX_DOC_LENGTH - 1)</td> </tr> <tr class="vc_row_odd" id="l522"> <td class="vc_file_line_number"><a href="#l522">522</a></td> <td class="vc_file_line_text"> i = MAX_DOC_LENGTH - 1;</td> </tr> <tr class="vc_row_odd" id="l523"> <td class="vc_file_line_number"><a href="#l523">523</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l524"> <td class="vc_file_line_number"><a href="#l524">524</a></td> <td class="vc_file_line_text"> i = content_length;</td> </tr> <tr class="vc_row_odd" id="l525"> <td class="vc_file_line_number"><a href="#l525">525</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l526"> <td class="vc_file_line_number"><a href="#l526">526</a></td> <td class="vc_file_line_text"> status = ksock_read_socket(ksock, b, &i);</td> </tr> <tr class="vc_row_odd" id="l527"> <td class="vc_file_line_number"><a href="#l527">527</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l528"> <td class="vc_file_line_number"><a href="#l528">528</a></td> <td class="vc_file_line_text"> content_length -= i;</td> </tr> <tr class="vc_row_odd" id="l529"> <td class="vc_file_line_number"><a href="#l529">529</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l530"> <td class="vc_file_line_number"><a href="#l530">530</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l531"> <td class="vc_file_line_number"><a href="#l531">531</a></td> <td class="vc_file_line_text"> else</td> </tr> <tr class="vc_row_odd" id="l532"> <td class="vc_file_line_number"><a href="#l532">532</a></td> <td class="vc_file_line_text"> {</td> </tr> <tr class="vc_row_odd" id="l533"> <td class="vc_file_line_number"><a href="#l533">533</a></td> <td class="vc_file_line_text"> while (status != APR_EGENERAL && status != APR_EOF && </td> </tr> <tr class="vc_row_odd" id="l534"> <td class="vc_file_line_number"><a href="#l534">534</a></td> <td class="vc_file_line_text"> status != APR_TIMEUP) {</td> </tr> <tr class="vc_row_odd" id="l535"> <td class="vc_file_line_number"><a href="#l535">535</a></td> <td class="vc_file_line_text"> i = MAX_DOC_LENGTH - 1;</td> </tr> <tr class="vc_row_odd" id="l536"> <td class="vc_file_line_number"><a href="#l536">536</a></td> <td class="vc_file_line_text"> status = ksock_read_socket(ksock, b, &i);</td> </tr> <tr class="vc_row_odd" id="l537"> <td class="vc_file_line_number"><a href="#l537">537</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l538"> <td class="vc_file_line_number"><a href="#l538">538</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l539"> <td class="vc_file_line_number"><a href="#l539">539</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l540"> <td class="vc_file_line_number"><a href="#l540">540</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l541"> <td class="vc_file_line_number"><a href="#l541">541</a></td> <td class="vc_file_line_text"> *resp = new_resp;</td> </tr> <tr class="vc_row_odd" id="l542"> <td class="vc_file_line_number"><a href="#l542">542</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l543"> <td class="vc_file_line_number"><a href="#l543">543</a></td> <td class="vc_file_line_text"> return APR_SUCCESS;</td> </tr> <tr class="vc_row_odd" id="l544"> <td class="vc_file_line_number"><a href="#l544">544</a></td> <td class="vc_file_line_text">}</td> </tr> <tr class="vc_row_odd" id="l545"> <td class="vc_file_line_number"><a href="#l545">545</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l546"> <td class="vc_file_line_number"><a href="#l546">546</a></td> <td class="vc_file_line_text">/**</td> </tr> <tr class="vc_row_odd" id="l547"> <td class="vc_file_line_number"><a href="#l547">547</a></td> <td class="vc_file_line_text"> * Keep-alive implementation for end_conn.</td> </tr> <tr class="vc_row_odd" id="l548"> <td class="vc_file_line_number"><a href="#l548">548</a></td> <td class="vc_file_line_text"> */</td> </tr> <tr class="vc_row_odd" id="l549"> <td class="vc_file_line_number"><a href="#l549">549</a></td> <td class="vc_file_line_text">apr_status_t keepalive_end_conn(socket_t *sock, request_t *req, response_t *resp)</td> </tr> <tr class="vc_row_odd" id="l550"> <td class="vc_file_line_number"><a href="#l550">550</a></td> <td class="vc_file_line_text">{</td> </tr> <tr class="vc_row_odd" id="l551"> <td class="vc_file_line_number"><a href="#l551">551</a></td> <td class="vc_file_line_text"> keepalive_socket_t *ksock = (keepalive_socket_t *)sock;</td> </tr> <tr class="vc_row_odd" id="l552"> <td class="vc_file_line_number"><a href="#l552">552</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l553"> <td class="vc_file_line_number"><a href="#l553">553</a></td> <td class="vc_file_line_text"> if (resp->keepalive == 0) {</td> </tr> <tr class="vc_row_odd" id="l554"> <td class="vc_file_line_number"><a href="#l554">554</a></td> <td class="vc_file_line_text"> ksock_close_socket(ksock);</td> </tr> <tr class="vc_row_odd" id="l555"> <td class="vc_file_line_number"><a href="#l555">555</a></td> <td class="vc_file_line_text"> ksock->reopen_socket = 1; /* we just closed it */</td> </tr> <tr class="vc_row_odd" id="l556"> <td class="vc_file_line_number"><a href="#l556">556</a></td> <td class="vc_file_line_text"> }</td> </tr> <tr class="vc_row_odd" id="l557"> <td class="vc_file_line_number"><a href="#l557">557</a></td> <td class="vc_file_line_text"> </td> </tr> <tr class="vc_row_odd" id="l558"> <td class="vc_file_line_number"><a href="#l558">558</a></td> <td class="vc_file_line_text"> return APR_SUCCESS;</td> </tr> <tr class="vc_row_odd" id="l559"> <td class="vc_file_line_number"><a href="#l559">559</a></td> <td class="vc_file_line_text">}</td> </tr> <tr class="vc_row_odd" id="l560"> <td class="vc_file_line_number"><a href="#l560">560</a></td> <td class="vc_file_line_text"></td> </tr> <tr class="vc_row_odd" id="l561"> <td class="vc_file_line_number"><a href="#l561">561</a></td> <td class="vc_file_line_text">apr_status_t keepalive_socket_destroy(socket_t *sock)</td> </tr> <tr class="vc_row_odd" id="l562"> <td class="vc_file_line_number"><a href="#l562">562</a></td> <td class="vc_file_line_text">{</td> </tr> <tr class="vc_row_odd" id="l563"> <td class="vc_file_line_number"><a href="#l563">563</a></td> <td class="vc_file_line_text"> return APR_SUCCESS;</td> </tr> <tr class="vc_row_odd" id="l564"> <td class="vc_file_line_number"><a href="#l564">564</a></td> <td class="vc_file_line_text">}</td> </tr> </table> </div> <hr/> <div class="vc_properties"> <h2>Properties</h2> <table cellspacing="1" cellpadding="2" class="auto"> <thead> <tr> <th class="vc_header_sort">Name</th> <th class="vc_header">Value</th> </tr> </thead> <tbody> <tr class="vc_row_even"> <td><strong>svn:eol-style</strong></td> <td style="white-space: pre;">native </td> </tr> </tbody> </table> </div> <hr /> <table> <tr> <td><address><a href="mailto:infrastructure at apache.org">infrastructure at apache.org</a></address></td> <td style="text-align: right;"><strong><a href="/vc-static/help_rootview.html">ViewVC Help</a></strong></td> </tr> <tr> <td>Powered by <a href="http://viewvc.tigris.org/">ViewVC 1.1.26</a></td> <td style="text-align: right;"> </td> </tr> </table> </body> </html>