You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

374 lines
74 KiB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.7"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Webserv: srcs/sock/Client.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">Webserv
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.7 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_b73b02d482d1c4a3db20c3d9ad52d395.html">srcs</a></li><li class="navelem"><a class="el" href="dir_b0f7ce2339e35a0e5afcbb3929376e00.html">sock</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">Client.cpp</div></div>
</div><!--header-->
<div class="contents">
<a href="Client_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="preprocessor">#include &quot;<a class="code" href="webserv_8hpp.html">webserv.hpp</a>&quot;</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"><a class="line" href="Client_8cpp.html#a11a04898e654ff6d1884f543f3051d23"> 10</a></span><span class="keyword">inline</span> <span class="keywordtype">string</span> <a class="code hl_function" href="Client_8cpp.html#a11a04898e654ff6d1884f543f3051d23">get_extension</a>(<span class="keywordtype">string</span> str) {</div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span> <span class="keywordtype">size_t</span> pos = str.rfind(<span class="charliteral">&#39;.&#39;</span>);</div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> <span class="keywordflow">if</span> (pos != string::npos)</div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span> <span class="keywordflow">return</span> str.substr(pos);</div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> <span class="keywordflow">return</span> <span class="stringliteral">&quot;&quot;</span>;</div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span>}</div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span> </div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"><a class="line" href="classClient.html#a084660f5c518a2fbd2e68411c0ef5ae8"> 18</a></span><a class="code hl_function" href="classClient.html#a084660f5c518a2fbd2e68411c0ef5ae8">Client::Client</a>(<span class="keywordtype">int</span> fd, <a class="code hl_struct" href="structip__port__s.html">ip_port_t</a> ip_port, <a class="code hl_class" href="classMaster.html">Master</a> *parent) : _fd(fd), _ip_port(ip_port), _parent(parent) {</div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> <a class="code hl_function" href="classClient.html#a5f6dcf73d3321725f64145bc065e1d1f">init</a>();</div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> cout &lt;&lt; <span class="stringliteral">&quot;New connection, socket fd is &quot;</span> &lt;&lt; fd &lt;&lt; <span class="stringliteral">&quot;, ip is : &quot;</span> &lt;&lt; <a class="code hl_variable" href="classClient.html#a7f318232807a0d483841ce22e1910bc7">_ip_port</a>.<a class="code hl_variable" href="structip__port__s.html#afb20776a9723a50ac32fd9b8248b3e0c">ip</a> &lt;&lt; <span class="stringliteral">&quot;, port : &quot;</span> &lt;&lt; <a class="code hl_variable" href="classClient.html#a7f318232807a0d483841ce22e1910bc7">_ip_port</a>.<a class="code hl_variable" href="structip__port__s.html#aae56f9ac0aa0193aaae11be127aa578e">port</a> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span>}</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> </div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"><a class="line" href="classClient.html#a66e3074e5f09c5e9bb4ec36bdea01c91"> 23</a></span><a class="code hl_function" href="classClient.html#a66e3074e5f09c5e9bb4ec36bdea01c91">Client::~Client</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> close(<a class="code hl_variable" href="classClient.html#a76a7d1bb0a940f1b180ac251b47e6cf4">_fd</a>);</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span> cout &lt;&lt; <span class="stringliteral">&quot;Host disconnected, ip &quot;</span> &lt;&lt; this-&gt;<a class="code hl_variable" href="classClient.html#a7f318232807a0d483841ce22e1910bc7">_ip_port</a>.<a class="code hl_variable" href="structip__port__s.html#afb20776a9723a50ac32fd9b8248b3e0c">ip</a> &lt;&lt; <span class="stringliteral">&quot;, port &quot;</span> &lt;&lt; this-&gt;<a class="code hl_variable" href="classClient.html#a7f318232807a0d483841ce22e1910bc7">_ip_port</a>.<a class="code hl_variable" href="structip__port__s.html#aae56f9ac0aa0193aaae11be127aa578e">port</a> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span>}</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> </div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"><a class="line" href="classClient.html#a5f6dcf73d3321725f64145bc065e1d1f"> 28</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classClient.html#a5f6dcf73d3321725f64145bc065e1d1f">Client::init</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> this-&gt;<a class="code hl_variable" href="classClient.html#a49268fda2ecee38b54f85581329b3920">_server</a> = NULL;</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> this-&gt;<a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a> = NULL;</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> this-&gt;<a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> = this-&gt;<a class="code hl_variable" href="classClient.html#a7af52bcb17cc9d34c2207d0e540f6ac1">_uri</a> = this-&gt;<a class="code hl_variable" href="classClient.html#a2ceac8ae6b5be095334bcfa495da4f4b">_host</a> = this-&gt;<a class="code hl_variable" href="classClient.html#abbbc980dcbfaf7db2cf1d50cac87cef6">_header</a> = this-&gt;<a class="code hl_variable" href="classClient.html#a1c3b8a2f750c8578d3bef07f2d9fe8f5">_body</a> = <span class="stringliteral">&quot;&quot;</span>;</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> this-&gt;<a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> = 0;</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> this-&gt;<a class="code hl_variable" href="classClient.html#ad76783880af38b42a854937101819ad2">_last_chunk</a> = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> this-&gt;<a class="code hl_variable" href="classClient.html#a502dd093f921afb109cddebf88e135b7">_request</a>.clear();</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span>}</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> </div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"><a class="line" href="classClient.html#acbcc94de0dd77b5635b574c9f23acdb8"> 37</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="classClient.html#acbcc94de0dd77b5635b574c9f23acdb8">Client::getRequest</a>(<a class="code hl_class" href="classEnv.html">Env</a> *env, <span class="keywordtype">string</span> paquet) {</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> <span class="keywordflow">if</span> (paquet.length() &lt; 1)</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> <a class="code hl_function" href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7">send_error</a>(403);</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> <span class="comment">//if (DEBUG)</span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> <a class="code hl_function" href="debug_8cpp.html#afb2639655e07c91426064b6bdfff7079">debug_block</a>(<span class="stringliteral">&quot;Paquet: &quot;</span>, paquet);</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <span class="keywordflow">if</span> (<a class="code hl_function" href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa">header_pick</a>(<span class="stringliteral">&quot;Method:&quot;</span>, 0) != <span class="stringliteral">&quot;&quot;</span>)</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> <span class="keywordflow">return</span> <a class="code hl_function" href="classClient.html#a8d671d9129091ed238c9833f4d3b5dda">getBody</a>(paquet);</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> <a class="code hl_typedef" href="webserv_8hpp.html#aba96a6988a5bc02b5c8b908af07d0bbb">vec_string</a> lines = <a class="code hl_function" href="tools_8cpp.html#a4a79e98b5dec14d16875307f7e77dfb3">split</a>(paquet, <span class="stringliteral">&quot;\r\n&quot;</span>);</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> <span class="keywordflow">for</span> (vec_string::iterator it = lines.begin(); it &lt; lines.end(); it++) {</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> <span class="keywordtype">size_t</span> pos = paquet.find(<span class="stringliteral">&quot;\r\n&quot;</span>);</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> <span class="keywordflow">if</span> (pos != string::npos)</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> paquet.erase(0, pos + 2);</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> paquet.clear();</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> <a class="code hl_variable" href="classClient.html#abbbc980dcbfaf7db2cf1d50cac87cef6">_header</a> += *it + (it + 1 != lines.end() ? <span class="stringliteral">&quot;\r\n&quot;</span> : <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="classClient.html#abbbc980dcbfaf7db2cf1d50cac87cef6">_header</a>.find(<span class="stringliteral">&quot;\r\n\r\n&quot;</span>) != string::npos)</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> <span class="keywordflow">return</span> !this-&gt;<a class="code hl_function" href="classClient.html#a3e6860ba08a116dcc3e75d97d91297c7">parseHeader</a>(env) ? false : (<a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> != 0 ? <a class="code hl_function" href="classClient.html#a8d671d9129091ed238c9833f4d3b5dda">getBody</a>(paquet) : <span class="keyword">true</span>);</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> }</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span>}</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> </div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"><a class="line" href="classClient.html#a8d671d9129091ed238c9833f4d3b5dda"> 58</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="classClient.html#a8d671d9129091ed238c9833f4d3b5dda">Client::getBody</a>(<span class="keywordtype">string</span> paquet) {</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <a class="code hl_typedef" href="webserv_8hpp.html#aba96a6988a5bc02b5c8b908af07d0bbb">vec_string</a> lines = <a class="code hl_function" href="tools_8cpp.html#a4a79e98b5dec14d16875307f7e77dfb3">split</a>(paquet, <span class="stringliteral">&quot;\r\n&quot;</span>);</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> vec_string::iterator it;</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> </div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> <span class="keywordflow">for</span> (it = lines.begin(); it &lt; lines.end(); it++) {</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> <span class="keywordflow">if</span> (<a class="code hl_define" href="webserv_8hpp.html#ad72dbcf6d0153db1b8d8a58001feed83">DEBUG</a>)</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> cout &lt;&lt; <span class="stringliteral">&quot;Remaining length: &quot;</span> &lt;&lt; <a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> <span class="keywordflow">if</span> ((*it).length() &amp;&amp; <a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> &lt;= 0 &amp;&amp; <a class="code hl_function" href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa">header_pick</a>(<span class="stringliteral">&quot;Transfer-Encoding:&quot;</span>, 0) == <span class="stringliteral">&quot;chunked&quot;</span>) {</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> = std::strtol((*it).c_str(), 0, 16) + 2;</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <a class="code hl_variable" href="classClient.html#ad76783880af38b42a854937101819ad2">_last_chunk</a> = <a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> == 2 ? true : <span class="keyword">false</span>;</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> &gt; 0 || it != lines.begin()) {</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <a class="code hl_variable" href="classClient.html#a1c3b8a2f750c8578d3bef07f2d9fe8f5">_body</a> += *it + <span class="stringliteral">&quot;\r\n&quot;</span>;</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> -= ((*it).length() + 2);</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> }</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> }</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <span class="comment">// if (_body.size())</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <a class="code hl_variable" href="classClient.html#a1c3b8a2f750c8578d3bef07f2d9fe8f5">_body</a>.resize(<a class="code hl_variable" href="classClient.html#a1c3b8a2f750c8578d3bef07f2d9fe8f5">_body</a>.length() - 2);</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> += 2;</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> <span class="keywordflow">return</span> (<a class="code hl_variable" href="classClient.html#ad76783880af38b42a854937101819ad2">_last_chunk</a> &amp;&amp; <a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> == 0) ? true : <span class="keyword">false</span>;</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span>}</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> </div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"><a class="line" href="classClient.html#a3e6860ba08a116dcc3e75d97d91297c7"> 79</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="classClient.html#a3e6860ba08a116dcc3e75d97d91297c7">Client::parseHeader</a>(<a class="code hl_class" href="classEnv.html">Env</a> *env) {</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <a class="code hl_typedef" href="webserv_8hpp.html#aba96a6988a5bc02b5c8b908af07d0bbb">vec_string</a> lines, method, line;</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> </div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> <span class="keywordflow">if</span> (<a class="code hl_define" href="webserv_8hpp.html#ad72dbcf6d0153db1b8d8a58001feed83">DEBUG</a>)</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> cout &lt;&lt; <span class="stringliteral">&quot;Parsing header...\n&quot;</span>;</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> lines = <a class="code hl_function" href="tools_8cpp.html#a4a79e98b5dec14d16875307f7e77dfb3">split</a>(<a class="code hl_variable" href="classClient.html#abbbc980dcbfaf7db2cf1d50cac87cef6">_header</a>, <span class="stringliteral">&quot;\r\n&quot;</span>);</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> method = <a class="code hl_function" href="tools_8cpp.html#a4a79e98b5dec14d16875307f7e77dfb3">split</a>(lines.at(0), <span class="stringliteral">&quot; &quot;</span>);</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> <a class="code hl_variable" href="classClient.html#a502dd093f921afb109cddebf88e135b7">_request</a>[<span class="stringliteral">&quot;Method:&quot;</span>] = method;</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> <span class="keywordflow">if</span> (lines.size() &gt; 0) {</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> <span class="keywordflow">for</span> (vec_string::iterator it = lines.begin() + 1; it &lt; lines.end(); it++) {</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> line = <a class="code hl_function" href="tools_8cpp.html#a4a79e98b5dec14d16875307f7e77dfb3">split</a>(*it, <span class="stringliteral">&quot; &quot;</span>);</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span> <a class="code hl_variable" href="classClient.html#a502dd093f921afb109cddebf88e135b7">_request</a>[line.at(0)] = <a class="code hl_typedef" href="webserv_8hpp.html#aba96a6988a5bc02b5c8b908af07d0bbb">vec_string</a>(line.begin() + 1, line.end());</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> }</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> }</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> <a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> = <a class="code hl_function" href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa">header_pick</a>(<span class="stringliteral">&quot;Method:&quot;</span>, 0);</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> <span class="keywordflow">if</span> ((<a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> == <span class="stringliteral">&quot;POST&quot;</span> || <a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> == <span class="stringliteral">&quot;PUT&quot;</span>) &amp;&amp; <a class="code hl_function" href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa">header_pick</a>(<span class="stringliteral">&quot;Content-Length:&quot;</span>, 0) == <span class="stringliteral">&quot;&quot;</span> &amp;&amp;</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> <a class="code hl_function" href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa">header_pick</a>(<span class="stringliteral">&quot;Transfer-Encoding:&quot;</span>, 0) != <span class="stringliteral">&quot;chunked&quot;</span>)</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="keywordflow">return</span> (<a class="code hl_function" href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7">send_error</a>(400), <span class="keyword">false</span>);</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> <a class="code hl_typedef" href="webserv_8hpp.html#aba96a6988a5bc02b5c8b908af07d0bbb">vec_string</a> uri_split = <a class="code hl_function" href="tools_8cpp.html#a4a79e98b5dec14d16875307f7e77dfb3">split</a>(<a class="code hl_function" href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa">header_pick</a>(<span class="stringliteral">&quot;Method:&quot;</span>, 1), <span class="stringliteral">&quot;?&quot;</span>);</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> <a class="code hl_variable" href="classClient.html#a7af52bcb17cc9d34c2207d0e540f6ac1">_uri</a> = uri_split.at(0);</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> <span class="keywordflow">if</span> (uri_split.size() &gt; 1)</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> <a class="code hl_variable" href="classClient.html#a7ac7f7134aa234289d43e9e1404226fd">_query</a> = uri_split.at(1);</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> <a class="code hl_variable" href="classClient.html#a2ceac8ae6b5be095334bcfa495da4f4b">_host</a> = <a class="code hl_function" href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa">header_pick</a>(<span class="stringliteral">&quot;Host:&quot;</span>, 0);</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> <a class="code hl_variable" href="classClient.html#a429e302dd255c112725f432f0ca9a1de">_env</a> = env;</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> <a class="code hl_variable" href="classClient.html#a49268fda2ecee38b54f85581329b3920">_server</a> = <a class="code hl_variable" href="classClient.html#a62889754be24e772908ce370f2ba0199">_parent</a>-&gt;<a class="code hl_function" href="classMaster.html#a5486cb0d32ba29cd31b212c3457942b1">choose_server</a>(env, <a class="code hl_variable" href="classClient.html#a2ceac8ae6b5be095334bcfa495da4f4b">_host</a>);</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> <a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a> = <a class="code hl_variable" href="classClient.html#a49268fda2ecee38b54f85581329b3920">_server</a>-&gt;<a class="code hl_function" href="classServer.html#a0664c62a66a7e3e41d48c286c55a90a9">choose_route</a>(<a class="code hl_variable" href="classClient.html#a7af52bcb17cc9d34c2207d0e540f6ac1">_uri</a>);</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> <span class="keywordflow">if</span> (<a class="code hl_define" href="webserv_8hpp.html#ad72dbcf6d0153db1b8d8a58001feed83">DEBUG</a>)</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> <a class="code hl_function" href="classClient.html#a1a58e00763626d48ee8625ad16a95d08">debug_header</a>();</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> <span class="keywordtype">string</span> len = <a class="code hl_function" href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa">header_pick</a>(<span class="stringliteral">&quot;Content-Length:&quot;</span>, 0).c_str();</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> <span class="keywordflow">if</span> (len != <span class="stringliteral">&quot;&quot;</span>) {</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> <a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> = std::atoi(len.c_str());</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> <a class="code hl_variable" href="classClient.html#ad76783880af38b42a854937101819ad2">_last_chunk</a> = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> <span class="keywordtype">int</span> max_len = <a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a>-&gt;<a class="code hl_variable" href="classRoute.html#a554deee37019d76b96a3411301b1d380">_client_max_body_size</a> &gt; 0 ? <a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a>-&gt;<a class="code hl_variable" href="classRoute.html#a554deee37019d76b96a3411301b1d380">_client_max_body_size</a></div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> : <a class="code hl_variable" href="classClient.html#a49268fda2ecee38b54f85581329b3920">_server</a>-&gt;<a class="code hl_variable" href="classRoute.html#a554deee37019d76b96a3411301b1d380">_client_max_body_size</a> &gt; 0 ? <a class="code hl_variable" href="classClient.html#a49268fda2ecee38b54f85581329b3920">_server</a>-&gt;<a class="code hl_variable" href="classRoute.html#a554deee37019d76b96a3411301b1d380">_client_max_body_size</a></div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> : INT_MAX;</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> &gt; max_len)</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <span class="keywordflow">return</span> (<a class="code hl_function" href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7">send_error</a>(413), <span class="keyword">false</span>);</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> } <span class="keywordflow">else</span></div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> <a class="code hl_variable" href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">_len</a> = 0;</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span>}</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> </div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"><a class="line" href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa"> 121</a></span><span class="keywordtype">string</span> <a class="code hl_function" href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa">Client::header_pick</a>(<span class="keywordtype">string</span> key, <span class="keywordtype">size_t</span> <span class="keywordtype">id</span>) { <span class="keywordflow">return</span> <a class="code hl_variable" href="classClient.html#a502dd093f921afb109cddebf88e135b7">_request</a>[key].size() &lt;= <span class="keywordtype">id</span> ? <span class="stringliteral">&quot;&quot;</span> : <a class="code hl_variable" href="classClient.html#a502dd093f921afb109cddebf88e135b7">_request</a>[key].at(<span class="keywordtype">id</span>); }</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> </div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"><a class="line" href="classClient.html#a674ad248447cc8ff80b4326d4fadfa6b"> 123</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="classClient.html#a674ad248447cc8ff80b4326d4fadfa6b">Client::check_method</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> <a class="code hl_typedef" href="webserv_8hpp.html#aba96a6988a5bc02b5c8b908af07d0bbb">vec_string</a> allowed;</div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> <span class="keywordflow">if</span> ((<a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a> &amp;&amp; (allowed = <a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a>-&gt;<a class="code hl_variable" href="classRoute.html#a3096f41064cf24c0c884d4c26f2fa07f">_allowed_methods</a>).size() &gt; 0) ||</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> (<a class="code hl_variable" href="classClient.html#a49268fda2ecee38b54f85581329b3920">_server</a> &amp;&amp; (allowed = <a class="code hl_variable" href="classClient.html#a49268fda2ecee38b54f85581329b3920">_server</a>-&gt;<a class="code hl_variable" href="classRoute.html#a3096f41064cf24c0c884d4c26f2fa07f">_allowed_methods</a>).size() &gt; 0) || ((allowed = <a class="code hl_variable" href="classClient.html#a429e302dd255c112725f432f0ca9a1de">_env</a>-&gt;<a class="code hl_variable" href="classEnv.html#af554adf3353c753d3e3050fc04bd297f">_allowed_methods</a>).size() &gt; 0))</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> <span class="keywordflow">return</span> std::find(allowed.begin(), allowed.end(), <a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a>) &lt; allowed.end() ? true : <span class="keyword">false</span>;</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> == <span class="stringliteral">&quot;GET&quot;</span> || <a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> == <span class="stringliteral">&quot;POST&quot;</span> || <a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> == <span class="stringliteral">&quot;DELETE&quot;</span> || <a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> == <span class="stringliteral">&quot;PUT&quot;</span>)</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <span class="keywordflow">return</span> (<span class="keyword">true</span>);</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> <span class="keywordflow">return</span> (<span class="keyword">false</span>);</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span>}</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> </div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"><a class="line" href="classClient.html#aa3fd6ca9ee860544e53a84cae96c19cb"> 133</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classClient.html#aa3fd6ca9ee860544e53a84cae96c19cb">Client::handleRequest</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> <span class="keywordflow">if</span> (<a class="code hl_define" href="webserv_8hpp.html#ad72dbcf6d0153db1b8d8a58001feed83">DEBUG</a>) {</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> <a class="code hl_function" href="debug_8cpp.html#afb2639655e07c91426064b6bdfff7079">debug_block</a>(<span class="stringliteral">&quot;Header: &quot;</span>, <a class="code hl_variable" href="classClient.html#abbbc980dcbfaf7db2cf1d50cac87cef6">_header</a>);</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> <a class="code hl_function" href="debug_8cpp.html#afb2639655e07c91426064b6bdfff7079">debug_block</a>(<span class="stringliteral">&quot;Body: &quot;</span>, <a class="code hl_variable" href="classClient.html#a1c3b8a2f750c8578d3bef07f2d9fe8f5">_body</a>);</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> }</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> <span class="keywordtype">string</span> ret;</div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span> <span class="keywordtype">string</span> req_path = <a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a>-&gt;<a class="code hl_function" href="classRoute.html#afd1fe00a85e85ac4964f618f8f2d7bdf">getRoot</a>() + <a class="code hl_variable" href="classClient.html#a7af52bcb17cc9d34c2207d0e540f6ac1">_uri</a>;</div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> std::cout &lt;&lt; <span class="stringliteral">&quot;||-&gt; Request for &quot;</span> &lt;&lt; req_path &lt;&lt; <span class="stringliteral">&quot; received &lt;-||\n&quot;</span>;</div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> <span class="keywordtype">string</span> cgi_path = <a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a>-&gt;<a class="code hl_variable" href="classRoute.html#a1688ba652b72bb3a1a0055e7e9cd3e41">_cgi</a>.size() ? <a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a>-&gt;<a class="code hl_variable" href="classRoute.html#a1688ba652b72bb3a1a0055e7e9cd3e41">_cgi</a>[<a class="code hl_function" href="Client_8cpp.html#a11a04898e654ff6d1884f543f3051d23">get_extension</a>(req_path)]</div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> : <a class="code hl_variable" href="classClient.html#a49268fda2ecee38b54f85581329b3920">_server</a>-&gt;<a class="code hl_variable" href="classRoute.html#a1688ba652b72bb3a1a0055e7e9cd3e41">_cgi</a>.size() ? <a class="code hl_variable" href="classClient.html#a49268fda2ecee38b54f85581329b3920">_server</a>-&gt;<a class="code hl_variable" href="classRoute.html#a1688ba652b72bb3a1a0055e7e9cd3e41">_cgi</a>[<a class="code hl_function" href="Client_8cpp.html#a11a04898e654ff6d1884f543f3051d23">get_extension</a>(req_path)]</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> : <span class="stringliteral">&quot;&quot;</span>;</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> <span class="keywordflow">if</span> (<a class="code hl_define" href="webserv_8hpp.html#ad72dbcf6d0153db1b8d8a58001feed83">DEBUG</a>)</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> cout &lt;&lt; <span class="stringliteral">&quot;Path: &quot;</span> &lt;&lt; req_path &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> <span class="keywordflow">if</span> (!<a class="code hl_function" href="classClient.html#a674ad248447cc8ff80b4326d4fadfa6b">check_method</a>())</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> <a class="code hl_function" href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7">send_error</a>(405);</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> <span class="keywordflow">if</span> ((ret = <a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a>-&gt;<a class="code hl_function" href="classRoute.html#aa71b39273ba7bc2f683f40a6573ff810">getIndex</a>(<a class="code hl_variable" href="classClient.html#a7af52bcb17cc9d34c2207d0e540f6ac1">_uri</a>, req_path)) == <span class="stringliteral">&quot;&quot;</span>)</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> ret = <a class="code hl_function" href="tools_8cpp.html#a044b9a41ee6f56019e039d36e91dc265">read_file</a>(req_path);</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> <span class="keywordflow">if</span> (ret == <span class="stringliteral">&quot;404&quot;</span>) {</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> == <span class="stringliteral">&quot;POST&quot;</span> || <a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> == <span class="stringliteral">&quot;PUT&quot;</span>)</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> <a class="code hl_function" href="classClient.html#a034a4f9166be42ffb3844b402a4f1881">create_file</a>(req_path);</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> <a class="code hl_function" href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7">send_error</a>(404);</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ret == <span class="stringliteral">&quot;403&quot;</span>)</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span> <a class="code hl_function" href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7">send_error</a>(403);</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="classClient.html#a6033d622cb33f0ea41313e859b621606">_method</a> == <span class="stringliteral">&quot;DELETE&quot;</span>)</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> std::remove(req_path.c_str());</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cgi_path != <span class="stringliteral">&quot;&quot;</span>)</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> <a class="code hl_function" href="classClient.html#a9f221331479aa9502ee2c372164095fc">cgi</a>(cgi_path, req_path);</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> <a class="code hl_function" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">send_answer</a>(<span class="stringliteral">&quot;HTTP/1.1 200 OK\r\n&quot;</span> + ret);</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> }</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span>}</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> </div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"><a class="line" href="classClient.html#a034a4f9166be42ffb3844b402a4f1881"> 167</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classClient.html#a034a4f9166be42ffb3844b402a4f1881">Client::create_file</a>(<span class="keywordtype">string</span> path) {</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> std::ofstream file(path.c_str());</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> <span class="keywordflow">if</span> (!file.good())</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> <a class="code hl_function" href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7">send_error</a>(403);</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</span> file &lt;&lt; <a class="code hl_variable" href="classClient.html#a1c3b8a2f750c8578d3bef07f2d9fe8f5">_body</a>;</div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"> 173</span> file.close();</div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno"> 174</span> <a class="code hl_function" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">send_answer</a>(<span class="stringliteral">&quot;HTTP/1.1 201 Accepted\r\nContent-Length: 0\r\n\r\n&quot;</span>);</div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"> 175</span> }</div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span>}</div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"> 177</span> </div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"><a class="line" href="classClient.html#a9f221331479aa9502ee2c372164095fc"> 178</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classClient.html#a9f221331479aa9502ee2c372164095fc">Client::cgi</a>(<span class="keywordtype">string</span> cgi_path, <span class="keywordtype">string</span> path) {</div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</span> <span class="keywordtype">int</span> status;</div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span> <span class="keywordtype">int</span> fd[2];</div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno"> 181</span> std::stringstream ss;</div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno"> 182</span> <span class="keywordtype">string</span> ret;</div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno"> 183</span> </div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno"> 184</span> <span class="keywordflow">if</span> (!std::ifstream(cgi_path.c_str()).good())</div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno"> 185</span> <span class="keywordflow">return</span> <a class="code hl_function" href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7">send_error</a>(404);</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno"> 186</span> pipe(fd);</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno"> 187</span> <span class="keywordflow">if</span> (fork() == 0) {</div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span> <span class="keyword">const</span> <span class="keywordtype">char</span> **args = <span class="keyword">new</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *[cgi_path.length() + path.length() + 2];</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"> 189</span> args[0] = cgi_path.c_str();</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span> args[1] = path.c_str();</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno"> 191</span> args[2] = NULL;</div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno"> 192</span> <span class="keywordtype">string</span> path_info = <span class="stringliteral">&quot;PATH_INFO=&quot;</span> + <a class="code hl_variable" href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">_route</a>-&gt;<a class="code hl_function" href="classRoute.html#afd1fe00a85e85ac4964f618f8f2d7bdf">getRoot</a>();</div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno"> 193</span> <span class="keywordtype">string</span> query = <span class="stringliteral">&quot;QUERY_STRING=&quot;</span> + <a class="code hl_variable" href="classClient.html#a7ac7f7134aa234289d43e9e1404226fd">_query</a>;</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno"> 194</span> <span class="keyword">const</span> <span class="keywordtype">char</span> **env = <span class="keyword">new</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *[path_info.length() + query.length() + 2];</div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"> 195</span> env[0] = path_info.c_str();</div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno"> 196</span> env[1] = query.c_str();</div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno"> 197</span> env[2] = NULL;</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"> 198</span> dup2(fd[1], STDOUT_FILENO);</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"> 199</span> close(fd[1]);</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno"> 200</span> close(fd[0]);</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno"> 201</span> execve(cgi_path.c_str(), (<span class="keywordtype">char</span> **)args, (<span class="keywordtype">char</span> **)env);</div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno"> 202</span> }</div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno"> 203</span> close(fd[1]);</div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno"> 204</span> waitpid(-1, &amp;status, 0);</div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno"> 205</span> <span class="keywordtype">char</span> buffer[10000];</div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno"> 206</span> buffer[read(fd[0], buffer, 10000)] = 0;</div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno"> 207</span> ret = string(buffer);</div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno"> 208</span> ss &lt;&lt; <span class="stringliteral">&quot;HTTP/1.1 200 OK\r\nContent-Length: &quot;</span> &lt;&lt; ret.length() - ret.find(<span class="stringliteral">&quot;\r\n\r\n&quot;</span>) - 4 &lt;&lt; <span class="stringliteral">&quot;\r\n\r\n&quot;</span> &lt;&lt; ret;</div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno"> 209</span> <a class="code hl_function" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">send_answer</a>(ss.str());</div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno"> 210</span>}</div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno"> 211</span> </div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno"><a class="line" href="classClient.html#a0c6bb0009c8415f9e49130cd7b6ecc8c"> 212</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classClient.html#a0c6bb0009c8415f9e49130cd7b6ecc8c">Client::send_redir</a>(<span class="keywordtype">int</span> redir_code, <span class="keywordtype">string</span> opt) {</div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno"> 213</span> <span class="keywordflow">switch</span> (redir_code) {</div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno"> 214</span> <span class="keywordflow">case</span> 301:</div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno"> 215</span> <span class="keywordflow">return</span> <a class="code hl_function" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">send_answer</a>(<span class="stringliteral">&quot;HTTTP/1.1 301 Moved Permanently\r\nLocation: &quot;</span> + opt + <span class="stringliteral">&quot;\r\n\r\n&quot;</span>);</div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno"> 216</span> }</div>
<div class="line"><a id="l00217" name="l00217"></a><span class="lineno"> 217</span>}</div>
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno"> 218</span> </div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno"><a class="line" href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7"> 219</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7">Client::send_error</a>(<span class="keywordtype">int</span> error_code) {</div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno"> 220</span> <span class="keywordflow">switch</span> (error_code) {</div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno"> 221</span> <span class="keywordflow">case</span> 400:</div>
<div class="line"><a id="l00222" name="l00222"></a><span class="lineno"> 222</span> <span class="keywordflow">return</span> <a class="code hl_function" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">send_answer</a>(<span class="stringliteral">&quot;HTTP/1.1 400 Bad Request\r\nContent-Length: 0\r\n\r\n&quot;</span>);</div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno"> 223</span> <span class="keywordflow">case</span> 403:</div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno"> 224</span> <span class="keywordflow">return</span> <a class="code hl_function" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">send_answer</a>(<span class="stringliteral">&quot;HTTP/1.1 403 Forbidden\r\nContent-Length: 0\r\n\r\n&quot;</span>);</div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno"> 225</span> <span class="keywordflow">case</span> 404:</div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno"> 226</span> <span class="keywordflow">return</span> <a class="code hl_function" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">send_answer</a>(<span class="stringliteral">&quot;HTTP/1.1 404 Not Found\r\nContent-Length: 0\r\n\r\n&quot;</span>);</div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno"> 227</span> <span class="keywordflow">case</span> 405:</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno"> 228</span> <span class="keywordflow">return</span> <a class="code hl_function" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">send_answer</a>(<span class="stringliteral">&quot;HTTP/1.1 405 Method Not Allowed\r\nConnection: &quot;</span></div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno"> 229</span> <span class="stringliteral">&quot;close\r\nContent-Length: 0\r\n\r\n&quot;</span>);</div>
<div class="line"><a id="l00230" name="l00230"></a><span class="lineno"> 230</span> <span class="keywordflow">case</span> 413:</div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno"> 231</span> <span class="keywordflow">return</span> <a class="code hl_function" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">send_answer</a>(<span class="stringliteral">&quot;HTTP/1.1 413 Payload Too &quot;</span></div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno"> 232</span> <span class="stringliteral">&quot;Large\r\nConnection: close\r\nContent-Length: 0\r\n\r\n&quot;</span>);</div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno"> 233</span> }</div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno"> 234</span>}</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno"> 235</span> </div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno"><a class="line" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540"> 236</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">Client::send_answer</a>(<span class="keywordtype">string</span> msg) {</div>
<div class="line"><a id="l00237" name="l00237"></a><span class="lineno"> 237</span> <span class="keywordflow">if</span> (<a class="code hl_define" href="webserv_8hpp.html#ad72dbcf6d0153db1b8d8a58001feed83">DEBUG</a>)</div>
<div class="line"><a id="l00238" name="l00238"></a><span class="lineno"> 238</span> <a class="code hl_function" href="debug_8cpp.html#afb2639655e07c91426064b6bdfff7079">debug_block</a>(<span class="stringliteral">&quot;ANSWER: &quot;</span>, msg);</div>
<div class="line"><a id="l00239" name="l00239"></a><span class="lineno"> 239</span><span class="preprocessor">#ifdef __linux__</span></div>
<div class="line"><a id="l00240" name="l00240"></a><span class="lineno"> 240</span> send(this-&gt;<a class="code hl_variable" href="classClient.html#a76a7d1bb0a940f1b180ac251b47e6cf4">_fd</a>, msg.c_str(), msg.length(), MSG_NOSIGNAL | MSG_DONTWAIT);</div>
<div class="line"><a id="l00241" name="l00241"></a><span class="lineno"> 241</span><span class="preprocessor">#elif __APPLE__</span></div>
<div class="line"><a id="l00242" name="l00242"></a><span class="lineno"> 242</span> send(this-&gt;<a class="code hl_variable" href="classClient.html#a76a7d1bb0a940f1b180ac251b47e6cf4">_fd</a>, msg.c_str(), msg.length(), 0);</div>
<div class="line"><a id="l00243" name="l00243"></a><span class="lineno"> 243</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00244" name="l00244"></a><span class="lineno"> 244</span> <a class="code hl_function" href="classClient.html#a5f6dcf73d3321725f64145bc065e1d1f">init</a>();</div>
<div class="line"><a id="l00245" name="l00245"></a><span class="lineno"> 245</span>}</div>
<div class="ttc" id="aClient_8cpp_html_a11a04898e654ff6d1884f543f3051d23"><div class="ttname"><a href="Client_8cpp.html#a11a04898e654ff6d1884f543f3051d23">get_extension</a></div><div class="ttdeci">string get_extension(string str)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00010">Client.cpp:10</a></div></div>
<div class="ttc" id="aclassClient_html_a034a4f9166be42ffb3844b402a4f1881"><div class="ttname"><a href="classClient.html#a034a4f9166be42ffb3844b402a4f1881">Client::create_file</a></div><div class="ttdeci">void create_file(string path)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00167">Client.cpp:167</a></div></div>
<div class="ttc" id="aclassClient_html_a084660f5c518a2fbd2e68411c0ef5ae8"><div class="ttname"><a href="classClient.html#a084660f5c518a2fbd2e68411c0ef5ae8">Client::Client</a></div><div class="ttdeci">Client(int fd, ip_port_t ip_port, Master *parent)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00018">Client.cpp:18</a></div></div>
<div class="ttc" id="aclassClient_html_a0c6bb0009c8415f9e49130cd7b6ecc8c"><div class="ttname"><a href="classClient.html#a0c6bb0009c8415f9e49130cd7b6ecc8c">Client::send_redir</a></div><div class="ttdeci">void send_redir(int redir_code, string opt)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00212">Client.cpp:212</a></div></div>
<div class="ttc" id="aclassClient_html_a1a58e00763626d48ee8625ad16a95d08"><div class="ttname"><a href="classClient.html#a1a58e00763626d48ee8625ad16a95d08">Client::debug_header</a></div><div class="ttdeci">void debug_header(void)</div><div class="ttdef"><b>Definition:</b> <a href="debug_8cpp_source.html#l00011">debug.cpp:11</a></div></div>
<div class="ttc" id="aclassClient_html_a1c3b8a2f750c8578d3bef07f2d9fe8f5"><div class="ttname"><a href="classClient.html#a1c3b8a2f750c8578d3bef07f2d9fe8f5">Client::_body</a></div><div class="ttdeci">string _body</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00011">Client.hpp:11</a></div></div>
<div class="ttc" id="aclassClient_html_a2ceac8ae6b5be095334bcfa495da4f4b"><div class="ttname"><a href="classClient.html#a2ceac8ae6b5be095334bcfa495da4f4b">Client::_host</a></div><div class="ttdeci">string _host</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00011">Client.hpp:11</a></div></div>
<div class="ttc" id="aclassClient_html_a3c5fe029aa5e2293d7c31e79dda7a937"><div class="ttname"><a href="classClient.html#a3c5fe029aa5e2293d7c31e79dda7a937">Client::_len</a></div><div class="ttdeci">int _len</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00012">Client.hpp:12</a></div></div>
<div class="ttc" id="aclassClient_html_a3e6860ba08a116dcc3e75d97d91297c7"><div class="ttname"><a href="classClient.html#a3e6860ba08a116dcc3e75d97d91297c7">Client::parseHeader</a></div><div class="ttdeci">bool parseHeader(Env *env)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00079">Client.cpp:79</a></div></div>
<div class="ttc" id="aclassClient_html_a429e302dd255c112725f432f0ca9a1de"><div class="ttname"><a href="classClient.html#a429e302dd255c112725f432f0ca9a1de">Client::_env</a></div><div class="ttdeci">Env * _env</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00009">Client.hpp:9</a></div></div>
<div class="ttc" id="aclassClient_html_a44bd2f49f7a1d456c8ae9c4b22302540"><div class="ttname"><a href="classClient.html#a44bd2f49f7a1d456c8ae9c4b22302540">Client::send_answer</a></div><div class="ttdeci">void send_answer(string msg)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00236">Client.cpp:236</a></div></div>
<div class="ttc" id="aclassClient_html_a49268fda2ecee38b54f85581329b3920"><div class="ttname"><a href="classClient.html#a49268fda2ecee38b54f85581329b3920">Client::_server</a></div><div class="ttdeci">Server * _server</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00008">Client.hpp:8</a></div></div>
<div class="ttc" id="aclassClient_html_a502dd093f921afb109cddebf88e135b7"><div class="ttname"><a href="classClient.html#a502dd093f921afb109cddebf88e135b7">Client::_request</a></div><div class="ttdeci">std::map&lt; string, vec_string &gt; _request</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00014">Client.hpp:14</a></div></div>
<div class="ttc" id="aclassClient_html_a5f6dcf73d3321725f64145bc065e1d1f"><div class="ttname"><a href="classClient.html#a5f6dcf73d3321725f64145bc065e1d1f">Client::init</a></div><div class="ttdeci">void init(void)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00028">Client.cpp:28</a></div></div>
<div class="ttc" id="aclassClient_html_a6033d622cb33f0ea41313e859b621606"><div class="ttname"><a href="classClient.html#a6033d622cb33f0ea41313e859b621606">Client::_method</a></div><div class="ttdeci">string _method</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00011">Client.hpp:11</a></div></div>
<div class="ttc" id="aclassClient_html_a612d8a71243e1fa5b29ec952a6804b66"><div class="ttname"><a href="classClient.html#a612d8a71243e1fa5b29ec952a6804b66">Client::_route</a></div><div class="ttdeci">Route * _route</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00010">Client.hpp:10</a></div></div>
<div class="ttc" id="aclassClient_html_a62889754be24e772908ce370f2ba0199"><div class="ttname"><a href="classClient.html#a62889754be24e772908ce370f2ba0199">Client::_parent</a></div><div class="ttdeci">Master * _parent</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00007">Client.hpp:7</a></div></div>
<div class="ttc" id="aclassClient_html_a66e3074e5f09c5e9bb4ec36bdea01c91"><div class="ttname"><a href="classClient.html#a66e3074e5f09c5e9bb4ec36bdea01c91">Client::~Client</a></div><div class="ttdeci">~Client(void)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00023">Client.cpp:23</a></div></div>
<div class="ttc" id="aclassClient_html_a674ad248447cc8ff80b4326d4fadfa6b"><div class="ttname"><a href="classClient.html#a674ad248447cc8ff80b4326d4fadfa6b">Client::check_method</a></div><div class="ttdeci">bool check_method(void)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00123">Client.cpp:123</a></div></div>
<div class="ttc" id="aclassClient_html_a76a7d1bb0a940f1b180ac251b47e6cf4"><div class="ttname"><a href="classClient.html#a76a7d1bb0a940f1b180ac251b47e6cf4">Client::_fd</a></div><div class="ttdeci">int _fd</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00005">Client.hpp:5</a></div></div>
<div class="ttc" id="aclassClient_html_a7ac7f7134aa234289d43e9e1404226fd"><div class="ttname"><a href="classClient.html#a7ac7f7134aa234289d43e9e1404226fd">Client::_query</a></div><div class="ttdeci">string _query</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00011">Client.hpp:11</a></div></div>
<div class="ttc" id="aclassClient_html_a7af52bcb17cc9d34c2207d0e540f6ac1"><div class="ttname"><a href="classClient.html#a7af52bcb17cc9d34c2207d0e540f6ac1">Client::_uri</a></div><div class="ttdeci">string _uri</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00011">Client.hpp:11</a></div></div>
<div class="ttc" id="aclassClient_html_a7f318232807a0d483841ce22e1910bc7"><div class="ttname"><a href="classClient.html#a7f318232807a0d483841ce22e1910bc7">Client::_ip_port</a></div><div class="ttdeci">ip_port_t _ip_port</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00006">Client.hpp:6</a></div></div>
<div class="ttc" id="aclassClient_html_a8d671d9129091ed238c9833f4d3b5dda"><div class="ttname"><a href="classClient.html#a8d671d9129091ed238c9833f4d3b5dda">Client::getBody</a></div><div class="ttdeci">bool getBody(string paquet)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00058">Client.cpp:58</a></div></div>
<div class="ttc" id="aclassClient_html_a9f221331479aa9502ee2c372164095fc"><div class="ttname"><a href="classClient.html#a9f221331479aa9502ee2c372164095fc">Client::cgi</a></div><div class="ttdeci">void cgi(string cgi_path, string path)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00178">Client.cpp:178</a></div></div>
<div class="ttc" id="aclassClient_html_aa3fd6ca9ee860544e53a84cae96c19cb"><div class="ttname"><a href="classClient.html#aa3fd6ca9ee860544e53a84cae96c19cb">Client::handleRequest</a></div><div class="ttdeci">void handleRequest(void)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00133">Client.cpp:133</a></div></div>
<div class="ttc" id="aclassClient_html_aab596e9a3653c01abb942bc6ee3001fa"><div class="ttname"><a href="classClient.html#aab596e9a3653c01abb942bc6ee3001fa">Client::header_pick</a></div><div class="ttdeci">string header_pick(string key, size_t id)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00121">Client.cpp:121</a></div></div>
<div class="ttc" id="aclassClient_html_abbbc980dcbfaf7db2cf1d50cac87cef6"><div class="ttname"><a href="classClient.html#abbbc980dcbfaf7db2cf1d50cac87cef6">Client::_header</a></div><div class="ttdeci">string _header</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00011">Client.hpp:11</a></div></div>
<div class="ttc" id="aclassClient_html_ac5ee168964331e90a3afcf8531f3cca7"><div class="ttname"><a href="classClient.html#ac5ee168964331e90a3afcf8531f3cca7">Client::send_error</a></div><div class="ttdeci">void send_error(int error_code)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00219">Client.cpp:219</a></div></div>
<div class="ttc" id="aclassClient_html_acbcc94de0dd77b5635b574c9f23acdb8"><div class="ttname"><a href="classClient.html#acbcc94de0dd77b5635b574c9f23acdb8">Client::getRequest</a></div><div class="ttdeci">bool getRequest(Env *env, string paquet)</div><div class="ttdef"><b>Definition:</b> <a href="Client_8cpp_source.html#l00037">Client.cpp:37</a></div></div>
<div class="ttc" id="aclassClient_html_ad76783880af38b42a854937101819ad2"><div class="ttname"><a href="classClient.html#ad76783880af38b42a854937101819ad2">Client::_last_chunk</a></div><div class="ttdeci">bool _last_chunk</div><div class="ttdef"><b>Definition:</b> <a href="Client_8hpp_source.html#l00013">Client.hpp:13</a></div></div>
<div class="ttc" id="aclassEnv_html"><div class="ttname"><a href="classEnv.html">Env</a></div><div class="ttdef"><b>Definition:</b> <a href="Env_8hpp_source.html#l00004">Env.hpp:4</a></div></div>
<div class="ttc" id="aclassEnv_html_af554adf3353c753d3e3050fc04bd297f"><div class="ttname"><a href="classEnv.html#af554adf3353c753d3e3050fc04bd297f">Env::_allowed_methods</a></div><div class="ttdeci">vec_string _allowed_methods</div><div class="ttdef"><b>Definition:</b> <a href="Env_8hpp_source.html#l00008">Env.hpp:8</a></div></div>
<div class="ttc" id="aclassMaster_html"><div class="ttname"><a href="classMaster.html">Master</a></div><div class="ttdef"><b>Definition:</b> <a href="Master_8hpp_source.html#l00004">Master.hpp:4</a></div></div>
<div class="ttc" id="aclassMaster_html_a5486cb0d32ba29cd31b212c3457942b1"><div class="ttname"><a href="classMaster.html#a5486cb0d32ba29cd31b212c3457942b1">Master::choose_server</a></div><div class="ttdeci">Server * choose_server(Env *env, string host)</div><div class="ttdef"><b>Definition:</b> <a href="Master_8cpp_source.html#l00113">Master.cpp:113</a></div></div>
<div class="ttc" id="aclassRoute_html_a1688ba652b72bb3a1a0055e7e9cd3e41"><div class="ttname"><a href="classRoute.html#a1688ba652b72bb3a1a0055e7e9cd3e41">Route::_cgi</a></div><div class="ttdeci">std::map&lt; string, string &gt; _cgi</div><div class="ttdef"><b>Definition:</b> <a href="Route_8hpp_source.html#l00012">Route.hpp:12</a></div></div>
<div class="ttc" id="aclassRoute_html_a3096f41064cf24c0c884d4c26f2fa07f"><div class="ttname"><a href="classRoute.html#a3096f41064cf24c0c884d4c26f2fa07f">Route::_allowed_methods</a></div><div class="ttdeci">vec_string _allowed_methods</div><div class="ttdef"><b>Definition:</b> <a href="Route_8hpp_source.html#l00011">Route.hpp:11</a></div></div>
<div class="ttc" id="aclassRoute_html_a554deee37019d76b96a3411301b1d380"><div class="ttname"><a href="classRoute.html#a554deee37019d76b96a3411301b1d380">Route::_client_max_body_size</a></div><div class="ttdeci">int _client_max_body_size</div><div class="ttdef"><b>Definition:</b> <a href="Route_8hpp_source.html#l00013">Route.hpp:13</a></div></div>
<div class="ttc" id="aclassRoute_html_aa71b39273ba7bc2f683f40a6573ff810"><div class="ttname"><a href="classRoute.html#aa71b39273ba7bc2f683f40a6573ff810">Route::getIndex</a></div><div class="ttdeci">string getIndex(string uri, string path)</div><div class="ttdoc">Search for an index while generating autoindex.</div><div class="ttdef"><b>Definition:</b> <a href="Route_8cpp_source.html#l00066">Route.cpp:66</a></div></div>
<div class="ttc" id="aclassRoute_html_afd1fe00a85e85ac4964f618f8f2d7bdf"><div class="ttname"><a href="classRoute.html#afd1fe00a85e85ac4964f618f8f2d7bdf">Route::getRoot</a></div><div class="ttdeci">string getRoot(void)</div><div class="ttdef"><b>Definition:</b> <a href="Route_8cpp_source.html#l00055">Route.cpp:55</a></div></div>
<div class="ttc" id="aclassServer_html_a0664c62a66a7e3e41d48c286c55a90a9"><div class="ttname"><a href="classServer.html#a0664c62a66a7e3e41d48c286c55a90a9">Server::choose_route</a></div><div class="ttdeci">Route * choose_route(string uri)</div><div class="ttdoc">Choose the route an uri asked to the server.</div><div class="ttdef"><b>Definition:</b> <a href="Server_8cpp_source.html#l00102">Server.cpp:102</a></div></div>
<div class="ttc" id="adebug_8cpp_html_afb2639655e07c91426064b6bdfff7079"><div class="ttname"><a href="debug_8cpp.html#afb2639655e07c91426064b6bdfff7079">debug_block</a></div><div class="ttdeci">void debug_block(string name, string content)</div><div class="ttdef"><b>Definition:</b> <a href="debug_8cpp_source.html#l00003">debug.cpp:3</a></div></div>
<div class="ttc" id="astructip__port__s_html"><div class="ttname"><a href="structip__port__s.html">ip_port_s</a></div><div class="ttdef"><b>Definition:</b> <a href="webserv_8hpp_source.html#l00035">webserv.hpp:35</a></div></div>
<div class="ttc" id="astructip__port__s_html_aae56f9ac0aa0193aaae11be127aa578e"><div class="ttname"><a href="structip__port__s.html#aae56f9ac0aa0193aaae11be127aa578e">ip_port_s::port</a></div><div class="ttdeci">int port</div><div class="ttdef"><b>Definition:</b> <a href="webserv_8hpp_source.html#l00038">webserv.hpp:38</a></div></div>
<div class="ttc" id="astructip__port__s_html_afb20776a9723a50ac32fd9b8248b3e0c"><div class="ttname"><a href="structip__port__s.html#afb20776a9723a50ac32fd9b8248b3e0c">ip_port_s::ip</a></div><div class="ttdeci">string ip</div><div class="ttdef"><b>Definition:</b> <a href="webserv_8hpp_source.html#l00037">webserv.hpp:37</a></div></div>
<div class="ttc" id="atools_8cpp_html_a044b9a41ee6f56019e039d36e91dc265"><div class="ttname"><a href="tools_8cpp.html#a044b9a41ee6f56019e039d36e91dc265">read_file</a></div><div class="ttdeci">string read_file(string path)</div><div class="ttdef"><b>Definition:</b> <a href="tools_8cpp_source.html#l00058">tools.cpp:58</a></div></div>
<div class="ttc" id="atools_8cpp_html_a4a79e98b5dec14d16875307f7e77dfb3"><div class="ttname"><a href="tools_8cpp.html#a4a79e98b5dec14d16875307f7e77dfb3">split</a></div><div class="ttdeci">vec_string split(string str, string delim)</div><div class="ttdef"><b>Definition:</b> <a href="tools_8cpp_source.html#l00020">tools.cpp:20</a></div></div>
<div class="ttc" id="awebserv_8hpp_html"><div class="ttname"><a href="webserv_8hpp.html">webserv.hpp</a></div></div>
<div class="ttc" id="awebserv_8hpp_html_aba96a6988a5bc02b5c8b908af07d0bbb"><div class="ttname"><a href="webserv_8hpp.html#aba96a6988a5bc02b5c8b908af07d0bbb">vec_string</a></div><div class="ttdeci">std::vector&lt; string &gt; vec_string</div><div class="ttdef"><b>Definition:</b> <a href="webserv_8hpp_source.html#l00050">webserv.hpp:50</a></div></div>
<div class="ttc" id="awebserv_8hpp_html_ad72dbcf6d0153db1b8d8a58001feed83"><div class="ttname"><a href="webserv_8hpp.html#ad72dbcf6d0153db1b8d8a58001feed83">DEBUG</a></div><div class="ttdeci">#define DEBUG</div><div class="ttdef"><b>Definition:</b> <a href="webserv_8hpp_source.html#l00002">webserv.hpp:2</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.7
</small></address>
</body>
</html>