mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
419 lines
54 KiB
HTML
419 lines
54 KiB
HTML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<!-- This file is generated by Nim. -->
|
|
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>std/asynchttpserver</title>
|
|
|
|
<!-- Google fonts -->
|
|
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
|
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
|
|
|
<!-- Favicon -->
|
|
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
|
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
|
|
|
<!-- CSS -->
|
|
<link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
|
|
|
|
<!-- JS -->
|
|
<script type="text/javascript" src="dochack.js?v=2.3.1"></script>
|
|
</head>
|
|
<body>
|
|
<div class="document" id="documentId">
|
|
<div class="container">
|
|
<h1 class="title">std/asynchttpserver</h1>
|
|
<div class="row">
|
|
<div class="three columns">
|
|
<div class="theme-select-wrapper">
|
|
<label for="theme-select">Theme: </label>
|
|
<select id="theme-select" onchange="setTheme(this.value)">
|
|
<option value="auto">🌗 Match OS</option>
|
|
<option value="dark">🌑 Dark</option>
|
|
<option value="light">🌕 Light</option>
|
|
</select>
|
|
</div>
|
|
<div id="global-links">
|
|
<ul class="simple-boot">
|
|
<li><a href="manual.html">Manual</a></li>
|
|
<li><a href="lib.html">Standard library</a></li>
|
|
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
|
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
|
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
|
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="searchInputDiv">
|
|
Search: <input type="search" id="searchInput"
|
|
oninput="search()" />
|
|
</div>
|
|
|
|
<ul class="simple simple-toc" id="toc-list">
|
|
<li>
|
|
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
|
</li>
|
|
<li>
|
|
<details open>
|
|
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
|
<ul class="simple simple-toc-section">
|
|
<li><a class="reference" href="#AsyncHttpServer" title="AsyncHttpServer = ref object">AsyncHttpServer</a></li>
|
|
<li><a class="reference" href="#Request" title="Request = object
|
|
client*: AsyncSocket
|
|
reqMethod*: HttpMethod
|
|
headers*: HttpHeaders
|
|
protocol*: tuple[orig: string, major, minor: int]
|
|
url*: Uri
|
|
hostname*: string ## The hostname of the client that made the request.
|
|
body*: string">Request</a></li>
|
|
|
|
</ul>
|
|
</details>
|
|
</li>
|
|
<li>
|
|
<details open>
|
|
<summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
|
|
<ul class="simple simple-toc-section">
|
|
<li><a class="reference" href="#nimMaxDescriptorsFallback" title="nimMaxDescriptorsFallback {.intdefine.} = 16000">nimMaxDescriptorsFallback</a></li>
|
|
|
|
</ul>
|
|
</details>
|
|
</li>
|
|
<li>
|
|
<details open>
|
|
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
|
<ul class="simple simple-toc-section">
|
|
<ul class="simple nested-toc-section">acceptRequest
|
|
<li><a class="reference" href="#acceptRequest%2CAsyncHttpServer%2Cproc%28Request%29" title="acceptRequest(server: AsyncHttpServer; callback: proc (request: Request): Future[
|
|
void] {.closure, gcsafe.}): owned(Future[void])">acceptRequest(server: AsyncHttpServer; callback: proc (request: Request): Future[
|
|
void] {.closure, gcsafe.}): owned(Future[void])</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">close
|
|
<li><a class="reference" href="#close%2CAsyncHttpServer" title="close(server: AsyncHttpServer)">close(server: AsyncHttpServer)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">getPort
|
|
<li><a class="reference" href="#getPort%2CAsyncHttpServer" title="getPort(self: AsyncHttpServer): Port">getPort(self: AsyncHttpServer): Port</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">listen
|
|
<li><a class="reference" href="#listen%2CAsyncHttpServer%2CPort%2Cstring" title="listen(server: AsyncHttpServer; port: Port; address = ""; domain = AF_INET)">listen(server: AsyncHttpServer; port: Port; address = ""; domain = AF_INET)</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">newAsyncHttpServer
|
|
<li><a class="reference" href="#newAsyncHttpServer%2Cint" title="newAsyncHttpServer(reuseAddr = true; reusePort = false; maxBody = 8388608): AsyncHttpServer">newAsyncHttpServer(reuseAddr = true; reusePort = false; maxBody = 8388608): AsyncHttpServer</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">respond
|
|
<li><a class="reference" href="#respond%2CRequest%2CHttpCode%2Cstring%2CHttpHeaders" title="respond(req: Request; code: HttpCode; content: string;
|
|
headers: HttpHeaders = nil): Future[void]">respond(req: Request; code: HttpCode; content: string;
|
|
headers: HttpHeaders = nil): Future[void]</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">sendHeaders
|
|
<li><a class="reference" href="#sendHeaders%2CRequest%2CHttpHeaders" title="sendHeaders(req: Request; headers: HttpHeaders): Future[void]">sendHeaders(req: Request; headers: HttpHeaders): Future[void]</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">serve
|
|
<li><a class="reference" href="#serve%2CAsyncHttpServer%2CPort%2Cproc%28Request%29%2Cstring%2Cint" title="serve(server: AsyncHttpServer; port: Port;
|
|
callback: proc (request: Request): Future[void] {.closure, gcsafe.};
|
|
address = ""; assumedDescriptorsPerRequest = -1; domain = AF_INET): owned(
|
|
Future[void])">serve(server: AsyncHttpServer; port: Port;
|
|
callback: proc (request: Request): Future[void] {.closure, gcsafe.};
|
|
address = ""; assumedDescriptorsPerRequest = -1; domain = AF_INET): owned(
|
|
Future[void])</a></li>
|
|
|
|
</ul>
|
|
<ul class="simple nested-toc-section">shouldAcceptRequest
|
|
<li><a class="reference" href="#shouldAcceptRequest%2CAsyncHttpServer%2Cint" title="shouldAcceptRequest(server: AsyncHttpServer; assumedDescriptorsPerRequest = 5): bool">shouldAcceptRequest(server: AsyncHttpServer; assumedDescriptorsPerRequest = 5): bool</a></li>
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
</details>
|
|
</li>
|
|
<li>
|
|
<a class="reference reference-toplevel" href="#19" id="69">Exports</a>
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
<div class="nine columns" id="content">
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
<div id="tocRoot"></div>
|
|
|
|
<p class="module-desc"><p>This module implements a high performance asynchronous HTTP server.</p>
|
|
<p>This HTTP server has not been designed to be used in production, but for testing applications locally. Because of this, when deploying your application in production you should use a reverse proxy (for example nginx) instead of allowing users to connect directly to this server.</p>
|
|
|
|
<p><strong class="examples_text">Example: cmd: -r:off</strong></p>
|
|
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">asynchttpserver</span>
|
|
<span class="Comment"># This example will create an HTTP server on an automatically chosen port.</span>
|
|
<span class="Comment"># It will respond to all requests with a `200 OK` response code and "Hello World"</span>
|
|
<span class="Comment"># as the response body.</span>
|
|
<span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">asyncdispatch</span>
|
|
<span class="Keyword">proc</span> <span class="Identifier">main</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
|
<span class="Keyword">var</span> <span class="Identifier">server</span> <span class="Operator">=</span> <span class="Identifier">newAsyncHttpServer</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">proc</span> <span class="Identifier">cb</span><span class="Punctuation">(</span><span class="Identifier">req</span><span class="Punctuation">:</span> <span class="Identifier">Request</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
|
<span class="Identifier">echo</span> <span class="Punctuation">(</span><span class="Identifier">req</span><span class="Operator">.</span><span class="Identifier">reqMethod</span><span class="Punctuation">,</span> <span class="Identifier">req</span><span class="Operator">.</span><span class="Identifier">url</span><span class="Punctuation">,</span> <span class="Identifier">req</span><span class="Operator">.</span><span class="Identifier">headers</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">headers</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"Content-type"</span><span class="Punctuation">:</span> <span class="StringLit">"text/plain; charset=utf-8"</span><span class="Punctuation">}</span>
|
|
<span class="Identifier">await</span> <span class="Identifier">req</span><span class="Operator">.</span><span class="Identifier">respond</span><span class="Punctuation">(</span><span class="Identifier">Http200</span><span class="Punctuation">,</span> <span class="StringLit">"Hello World"</span><span class="Punctuation">,</span> <span class="Identifier">headers</span><span class="Operator">.</span><span class="Identifier">newHttpHeaders</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">listen</span><span class="Punctuation">(</span><span class="Identifier">Port</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Comment"># or Port(8080) to hardcode the standard HTTP port.</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">port</span> <span class="Operator">=</span> <span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">getPort</span>
|
|
<span class="Identifier">echo</span> <span class="StringLit">"test this with: curl localhost:"</span> <span class="Operator">&</span> <span class="Operator">$</span><span class="Identifier">port</span><span class="Operator">.</span><span class="Identifier">uint16</span> <span class="Operator">&</span> <span class="StringLit">"/"</span>
|
|
<span class="Keyword">while</span> <span class="Identifier">true</span><span class="Punctuation">:</span>
|
|
<span class="Keyword">if</span> <span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">shouldAcceptRequest</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
|
|
<span class="Identifier">await</span> <span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">acceptRequest</span><span class="Punctuation">(</span><span class="Identifier">cb</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">else</span><span class="Punctuation">:</span>
|
|
<span class="Comment"># too many concurrent connections, `maxFDs` exceeded</span>
|
|
<span class="Comment"># wait 500ms for FDs to be closed</span>
|
|
<span class="Identifier">await</span> <span class="Identifier">sleepAsync</span><span class="Punctuation">(</span><span class="DecNumber">500</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Identifier">waitFor</span> <span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
|
|
<div class="section" id="6">
|
|
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
|
<dl class="item">
|
|
<a class="reference external" href="asyncnet.html">asyncnet</a>, <a class="reference external" href="asyncdispatch.html">asyncdispatch</a>, <a class="reference external" href="parseutils.html">parseutils</a>, <a class="reference external" href="uri.html">uri</a>, <a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="httpcore.html">httpcore</a>, <a class="reference external" href="nativesockets.html">nativesockets</a>, <a class="reference external" href="since.html">since</a>, <a class="reference external" href="assertions.html">assertions</a>
|
|
</dl>
|
|
</div>
|
|
<div class="section" id="7">
|
|
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
|
<dl class="item">
|
|
<div id="AsyncHttpServer">
|
|
<dt><pre><a href="asynchttpserver.html#AsyncHttpServer"><span class="Identifier">AsyncHttpServer</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L70" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L70" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
<div id="Request">
|
|
<dt><pre><a href="asynchttpserver.html#Request"><span class="Identifier">Request</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">client</span><span class="Operator">*</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a>
|
|
<span class="Identifier">reqMethod</span><span class="Operator">*</span><span class="Other">:</span> <a href="httpcore.html#HttpMethod"><span class="Identifier">HttpMethod</span></a>
|
|
<span class="Identifier">headers</span><span class="Operator">*</span><span class="Other">:</span> <a href="httpcore.html#HttpHeaders"><span class="Identifier">HttpHeaders</span></a>
|
|
<span class="Identifier">protocol</span><span class="Operator">*</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">orig</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">major</span><span class="Other">,</span> <span class="Identifier">minor</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span>
|
|
<span class="Identifier">url</span><span class="Operator">*</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a>
|
|
<span class="Identifier">hostname</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Comment">## The hostname of the client that made the request.</span>
|
|
<span class="Identifier">body</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a></pre></dt>
|
|
<dd>
|
|
|
|
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L61" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L61" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</dl>
|
|
</div>
|
|
<div class="section" id="10">
|
|
<h1><a class="toc-backref" href="#10">Consts</a></h1>
|
|
<dl class="item">
|
|
<div id="nimMaxDescriptorsFallback">
|
|
<dt><pre><a href="asynchttpserver.html#nimMaxDescriptorsFallback"><span class="Identifier">nimMaxDescriptorsFallback</span></a> {.<span class="Identifier">intdefine</span>.} <span class="Other">=</span> <span class="DecNumber">16000</span></pre></dt>
|
|
<dd>
|
|
|
|
fallback value for
|
|
when <tt class="docutils literal"><span class="pre"><span class="Identifier">maxDescriptors</span></span></tt> is not available. This can be set on the command line during compilation via <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">nimMaxDescriptorsFallback</span><span class="Operator">=</span><span class="Identifier">N</span></span></tt>
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L377" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L377" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</dl>
|
|
</div>
|
|
<div class="section" id="12">
|
|
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
|
<dl class="item">
|
|
<div id="acceptRequest-procs-all">
|
|
<div id="acceptRequest,AsyncHttpServer,proc(Request)">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#acceptRequest%2CAsyncHttpServer%2Cproc%28Request%29"><span class="Identifier">acceptRequest</span></a><span class="Other">(</span><span class="Identifier">server</span><span class="Other">:</span> <a href="asynchttpserver.html#AsyncHttpServer"><span class="Identifier">AsyncHttpServer</span></a><span class="Other">;</span> <span class="Identifier">callback</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">request</span><span class="Other">:</span> <a href="asynchttpserver.html#Request"><span class="Identifier">Request</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span>
|
|
<a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span><span class="Other">:</span> <a href="system.html#owned"><span class="Identifier">owned</span></a><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
|
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">SslError</span><span class="Other">,</span> <span class="Identifier">LibraryError</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
Accepts a single request. Write an explicit loop around this proc so that errors can be handled properly.
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L406" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L406" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="close-procs-all">
|
|
<div id="close,AsyncHttpServer">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#close%2CAsyncHttpServer"><span class="Identifier">close</span></a><span class="Other">(</span><span class="Identifier">server</span><span class="Other">:</span> <a href="asynchttpserver.html#AsyncHttpServer"><span class="Identifier">AsyncHttpServer</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">LibraryError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">SslError</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
Terminates the async http server instance.
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L439" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L439" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="getPort-procs-all">
|
|
<div id="getPort,AsyncHttpServer">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#getPort%2CAsyncHttpServer"><span class="Identifier">getPort</span></a><span class="Other">(</span><span class="Identifier">self</span><span class="Other">:</span> <a href="asynchttpserver.html#AsyncHttpServer"><span class="Identifier">AsyncHttpServer</span></a><span class="Other">)</span><span class="Other">:</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>Returns the port <tt class="docutils literal"><span class="pre"><span class="Identifier">self</span></span></tt> was bound to.</p>
|
|
<p>Useful for identifying what port <tt class="docutils literal"><span class="pre"><span class="Identifier">self</span></span></tt> is bound to, if it was chosen automatically, for example via <tt class="docutils literal"><span class="pre"><span class="Identifier">listen</span><span class="Punctuation">(</span><span class="Identifier">Port</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span><span class="Punctuation">)</span></span></tt>.</p>
|
|
|
|
<p><strong class="examples_text">Example:</strong></p>
|
|
<pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">nativesockets</span> <span class="Keyword">import</span> <span class="Identifier">Port</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">server</span> <span class="Operator">=</span> <span class="Identifier">newAsyncHttpServer</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">listen</span><span class="Punctuation">(</span><span class="Identifier">Port</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">assert</span> <span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">getPort</span><span class="Operator">.</span><span class="Identifier">uint16</span> <span class="Operator">></span> <span class="DecNumber">0</span>
|
|
<span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre>
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L77" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L77" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="listen-procs-all">
|
|
<div id="listen,AsyncHttpServer,Port,string">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#listen%2CAsyncHttpServer%2CPort%2Cstring"><span class="Identifier">listen</span></a><span class="Other">(</span><span class="Identifier">server</span><span class="Other">:</span> <a href="asynchttpserver.html#AsyncHttpServer"><span class="Identifier">AsyncHttpServer</span></a><span class="Other">;</span> <span class="Identifier">port</span><span class="Other">:</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">;</span> <span class="Identifier">address</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">domain</span> <span class="Other">=</span> <span class="Identifier">AF_INET</span><span class="Other">)</span> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span>
|
|
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
Listen to the given port and address.
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L382" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L382" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="newAsyncHttpServer-procs-all">
|
|
<div id="newAsyncHttpServer,int">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#newAsyncHttpServer%2Cint"><span class="Identifier">newAsyncHttpServer</span></a><span class="Other">(</span><span class="Identifier">reuseAddr</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">;</span> <span class="Identifier">reusePort</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">;</span> <span class="Identifier">maxBody</span> <span class="Other">=</span> <span class="DecNumber">8388608</span><span class="Other">)</span><span class="Other">:</span> <a href="asynchttpserver.html#AsyncHttpServer"><span class="Identifier">AsyncHttpServer</span></a> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
Creates a new <tt class="docutils literal"><span class="pre"><span class="Identifier">AsyncHttpServer</span></span></tt> instance.
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L90" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L90" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="respond-procs-all">
|
|
<div id="respond,Request,HttpCode,string,HttpHeaders">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#respond%2CRequest%2CHttpCode%2Cstring%2CHttpHeaders"><span class="Identifier">respond</span></a><span class="Other">(</span><span class="Identifier">req</span><span class="Other">:</span> <a href="asynchttpserver.html#Request"><span class="Identifier">Request</span></a><span class="Other">;</span> <span class="Identifier">code</span><span class="Other">:</span> <a href="httpcore.html#HttpCode"><span class="Identifier">HttpCode</span></a><span class="Other">;</span> <span class="Identifier">content</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span>
|
|
<span class="Identifier">headers</span><span class="Other">:</span> <a href="httpcore.html#HttpHeaders"><span class="Identifier">HttpHeaders</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">SslError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>Responds to the request with the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">HttpCode</span></span></tt>, headers and content.</p>
|
|
<p>This procedure will <strong>not</strong> close the client socket.</p>
|
|
<p>Example:</p>
|
|
<p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">json</span>
|
|
<span class="Keyword">proc</span> <span class="Identifier">handler</span><span class="Punctuation">(</span><span class="Identifier">req</span><span class="Punctuation">:</span> <span class="Identifier">Request</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
|
<span class="Keyword">if</span> <span class="Identifier">req</span><span class="Operator">.</span><span class="Identifier">url</span><span class="Operator">.</span><span class="Identifier">path</span> <span class="Operator">==</span> <span class="StringLit">"/hello-world"</span><span class="Punctuation">:</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">msg</span> <span class="Operator">=</span> <span class="Operator">%*</span> <span class="Punctuation">{</span><span class="StringLit">"message"</span><span class="Punctuation">:</span> <span class="StringLit">"Hello World"</span><span class="Punctuation">}</span>
|
|
<span class="Keyword">let</span> <span class="Identifier">headers</span> <span class="Operator">=</span> <span class="Identifier">newHttpHeaders</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="StringLit">"Content-Type"</span><span class="Punctuation">,</span><span class="StringLit">"application/json"</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">await</span> <span class="Identifier">req</span><span class="Operator">.</span><span class="Identifier">respond</span><span class="Punctuation">(</span><span class="Identifier">Http200</span><span class="Punctuation">,</span> <span class="Operator">$</span><span class="Identifier">msg</span><span class="Punctuation">,</span> <span class="Identifier">headers</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">else</span><span class="Punctuation">:</span>
|
|
<span class="Identifier">await</span> <span class="Identifier">req</span><span class="Operator">.</span><span class="Identifier">respond</span><span class="Punctuation">(</span><span class="Identifier">Http404</span><span class="Punctuation">,</span> <span class="StringLit">"Not Found"</span><span class="Punctuation">)</span></pre></p>
|
|
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L105" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L105" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="sendHeaders-procs-all">
|
|
<div id="sendHeaders,Request,HttpHeaders">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#sendHeaders%2CRequest%2CHttpHeaders"><span class="Identifier">sendHeaders</span></a><span class="Other">(</span><span class="Identifier">req</span><span class="Other">:</span> <a href="asynchttpserver.html#Request"><span class="Identifier">Request</span></a><span class="Other">;</span> <span class="Identifier">headers</span><span class="Other">:</span> <a href="httpcore.html#HttpHeaders"><span class="Identifier">HttpHeaders</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span> {.
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">SslError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
Sends the specified headers to the requesting client.
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L99" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L99" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="serve-procs-all">
|
|
<div id="serve,AsyncHttpServer,Port,proc(Request),string,int">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#serve%2CAsyncHttpServer%2CPort%2Cproc%28Request%29%2Cstring%2Cint"><span class="Identifier">serve</span></a><span class="Other">(</span><span class="Identifier">server</span><span class="Other">:</span> <a href="asynchttpserver.html#AsyncHttpServer"><span class="Identifier">AsyncHttpServer</span></a><span class="Other">;</span> <span class="Identifier">port</span><span class="Other">:</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">;</span>
|
|
<span class="Identifier">callback</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">request</span><span class="Other">:</span> <a href="asynchttpserver.html#Request"><span class="Identifier">Request</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">;</span>
|
|
<span class="Identifier">address</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">assumedDescriptorsPerRequest</span> <span class="Other">=</span> <span class="DecNumber">-1</span><span class="Other">;</span> <span class="Identifier">domain</span> <span class="Other">=</span> <span class="Identifier">AF_INET</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#owned"><span class="Identifier">owned</span></a><span class="Other">(</span>
|
|
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">,</span>
|
|
<span class="Identifier">SslError</span><span class="Other">,</span> <span class="Identifier">LibraryError</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span>
|
|
<span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
<p>Starts the process of listening for incoming HTTP connections on the specified address and port.</p>
|
|
<p>When a request is made by a client the specified callback will be called.</p>
|
|
<p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">assumedDescriptorsPerRequest</span></span></tt> is 0 or greater the server cares about the process's maximum file descriptor limit. It then ensures that the process still has the resources for <tt class="docutils literal"><span class="pre"><span class="Identifier">assumedDescriptorsPerRequest</span></span></tt> file descriptors before accepting a connection.</p>
|
|
<p>You should prefer to call <tt class="docutils literal"><span class="pre"><span class="Identifier">acceptRequest</span></span></tt> instead with a custom server loop so that you're in control over the error handling and logging.</p>
|
|
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L416" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L416" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="shouldAcceptRequest-procs-all">
|
|
<div id="shouldAcceptRequest,AsyncHttpServer,int">
|
|
<dt><pre><span class="Keyword">proc</span> <a href="#shouldAcceptRequest%2CAsyncHttpServer%2Cint"><span class="Identifier">shouldAcceptRequest</span></a><span class="Other">(</span><span class="Identifier">server</span><span class="Other">:</span> <a href="asynchttpserver.html#AsyncHttpServer"><span class="Identifier">AsyncHttpServer</span></a><span class="Other">;</span>
|
|
<span class="Identifier">assumedDescriptorsPerRequest</span> <span class="Other">=</span> <span class="DecNumber">5</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span>
|
|
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
|
<dd>
|
|
|
|
Returns true if the process's current number of opened file descriptors is still within the maximum limit and so it's reasonable to accept yet another request.
|
|
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asynchttpserver.nim#L397" class="link-seesrc" target="_blank">Source</a>
|
|
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asynchttpserver.nim#L397" class="link-seesrc" target="_blank" >Edit</a>
|
|
|
|
</dd>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</dl>
|
|
</div>
|
|
<div class="section" id="19">
|
|
<h1><a class="toc-backref" href="#19">Exports</a></h1>
|
|
<dl class="item">
|
|
<a href="httpcore.html#Http417"><span class="Identifier">Http417</span></a>, <a href="httpcore.html#Http503"><span class="Identifier">Http503</span></a>, <a href="httpcore.html#Http431"><span class="Identifier">Http431</span></a>, <a href="httpcore.html#HttpTrace"><span class="Identifier">HttpTrace</span></a>, <a href="httpcore.html#contains,set[HttpMethod],string"><span class="Identifier">contains</span></a>, <a href="httpcore.html#Http304"><span class="Identifier">Http304</span></a>, <a href="httpcore.html#Http406"><span class="Identifier">Http406</span></a>, <a href="httpcore.html#Http301"><span class="Identifier">Http301</span></a>, <a href="httpcore.html#$,HttpHeaders"><span class="Identifier">$</span></a>, <a href="httpcore.html#HttpMethod"><span class="Identifier">HttpMethod</span></a>, <a href="httpcore.html#Http408"><span class="Identifier">Http408</span></a>, <a href="httpcore.html#is4xx,HttpCode"><span class="Identifier">is4xx</span></a>, <a href="httpcore.html#is1xx,HttpCode"><span class="Identifier">is1xx</span></a>, <a href="httpcore.html#Http411"><span class="Identifier">Http411</span></a>, <a href="httpcore.html#is3xx,HttpCode"><span class="Identifier">is3xx</span></a>, <a href="httpcore.html#Http207"><span class="Identifier">Http207</span></a>, <a href="httpcore.html#Http418"><span class="Identifier">Http418</span></a>, <a href="httpcore.html#Http206"><span class="Identifier">Http206</span></a>, <a href="httpcore.html#toString.c,HttpHeaderValues"><span class="Identifier">toString</span></a>, <a href="httpcore.html#HttpPost"><span class="Identifier">HttpPost</span></a>, <a href="httpcore.html#clear,HttpHeaders"><span class="Identifier">clear</span></a>, <a href="httpcore.html#Http101"><span class="Identifier">Http101</span></a>, <a href="httpcore.html#httpNewLine"><span class="Identifier">httpNewLine</span></a>, <a href="httpcore.html#Http505"><span class="Identifier">Http505</span></a>, <a href="httpcore.html#Http413"><span class="Identifier">Http413</span></a>, <a href="httpcore.html#Http423"><span class="Identifier">Http423</span></a>, <a href="httpcore.html#Http409"><span class="Identifier">Http409</span></a>, <a href="httpcore.html#hasKey,HttpHeaders,string"><span class="Identifier">hasKey</span></a>, <a href="httpcore.html#Http200"><span class="Identifier">Http200</span></a>, <a href="httpcore.html#[]=,HttpHeaders,string,seq[string]"><span class="Identifier">[]=</span></a>, <a href="httpcore.html#Http414"><span class="Identifier">Http414</span></a>, <a href="httpcore.html#add,HttpHeaders,string,string"><span class="Identifier">add</span></a>, <a href="httpcore.html#Http401"><span class="Identifier">Http401</span></a>, <a href="httpcore.html#Http511"><span class="Identifier">Http511</span></a>, <a href="httpcore.html#Http205"><span class="Identifier">Http205</span></a>, <a href="httpcore.html#==,HttpCode,HttpCode"><span class="Identifier">==</span></a>, <a href="httpcore.html#Http407"><span class="Identifier">Http407</span></a>, <a href="httpcore.html#Http500"><span class="Identifier">Http500</span></a>, <a href="httpcore.html#Http404"><span class="Identifier">Http404</span></a>, <a href="httpcore.html#Http416"><span class="Identifier">Http416</span></a>, <a href="httpcore.html#Http507"><span class="Identifier">Http507</span></a>, <a href="httpcore.html#Http302"><span class="Identifier">Http302</span></a>, <a href="httpcore.html#HttpHeaders"><span class="Identifier">HttpHeaders</span></a>, <a href="httpcore.html#Http300"><span class="Identifier">Http300</span></a>, <a href="httpcore.html#Http428"><span class="Identifier">Http428</span></a>, <a href="httpcore.html#Http410"><span class="Identifier">Http410</span></a>, <a href="httpcore.html#is2xx,HttpCode"><span class="Identifier">is2xx</span></a>, <a href="httpcore.html#Http202"><span class="Identifier">Http202</span></a>, <a href="httpcore.html#Http502"><span class="Identifier">Http502</span></a>, <a href="httpcore.html#headerLimit"><span class="Identifier">headerLimit</span></a>, <a href="httpcore.html#HttpHeaderValues"><span class="Identifier">HttpHeaderValues</span></a>, <a href="httpcore.html#Http425"><span class="Identifier">Http425</span></a>, <a href="httpcore.html#contains,HttpHeaderValues,string"><span class="Identifier">contains</span></a>, <a href="httpcore.html#newHttpHeaders"><span class="Identifier">newHttpHeaders</span></a>, <a href="httpcore.html#$,HttpCode"><span class="Identifier">$</span></a>, <a href="httpcore.html#[],HttpHeaders,string,int"><span class="Identifier">[]</span></a>, <a href="httpcore.html#Http510"><span class="Identifier">Http510</span></a>, <a href="httpcore.html#newHttpHeaders,openArray[tuple[string,string]]"><span class="Identifier">newHttpHeaders</span></a>, <a href="httpcore.html#Http305"><span class="Identifier">Http305</span></a>, <a href="httpcore.html#Http451"><span class="Identifier">Http451</span></a>, <a href="httpcore.html#Http504"><span class="Identifier">Http504</span></a>, <a href="httpcore.html#Http426"><span class="Identifier">Http426</span></a>, <a href="httpcore.html#HttpConnect"><span class="Identifier">HttpConnect</span></a>, <a href="httpcore.html#==,tuple[string,int,int],HttpVersion"><span class="Identifier">==</span></a>, <a href="httpcore.html#Http308"><span class="Identifier">Http308</span></a>, <a href="httpcore.html#del,HttpHeaders,string"><span class="Identifier">del</span></a>, <a href="httpcore.html#HttpPut"><span class="Identifier">HttpPut</span></a>, <a href="httpcore.html#Http402"><span class="Identifier">Http402</span></a>, <a href="httpcore.html#pairs.i,HttpHeaders"><span class="Identifier">pairs</span></a>, <a href="httpcore.html#Http429"><span class="Identifier">Http429</span></a>, <a href="httpcore.html#HttpVersion"><span class="Identifier">HttpVersion</span></a>, <a href="httpcore.html#HttpDelete"><span class="Identifier">HttpDelete</span></a>, <a href="httpcore.html#is5xx,HttpCode"><span class="Identifier">is5xx</span></a>, <a href="httpcore.html#Http421"><span class="Identifier">Http421</span></a>, <a href="httpcore.html#HttpOptions"><span class="Identifier">HttpOptions</span></a>, <a href="httpcore.html#Http307"><span class="Identifier">Http307</span></a>, <a href="httpcore.html#Http102"><span class="Identifier">Http102</span></a>, <a href="httpcore.html#toCaseInsensitive,HttpHeaders,string"><span class="Identifier">toCaseInsensitive</span></a>, <a href="httpcore.html#HttpPatch"><span class="Identifier">HttpPatch</span></a>, <a href="httpcore.html#Http201"><span class="Identifier">Http201</span></a>, <a href="httpcore.html#Http203"><span class="Identifier">Http203</span></a>, <a href="httpcore.html#getOrDefault,HttpHeaders,string"><span class="Identifier">getOrDefault</span></a>, <a href="httpcore.html#Http100"><span class="Identifier">Http100</span></a>, <a href="httpcore.html#Http208"><span class="Identifier">Http208</span></a>, <a href="httpcore.html#Http501"><span class="Identifier">Http501</span></a>, <a href="httpcore.html#[]=,HttpHeaders,string,string"><span class="Identifier">[]=</span></a>, <a href="httpcore.html#len,HttpHeaders"><span class="Identifier">len</span></a>, <a href="httpcore.html#Http506"><span class="Identifier">Http506</span></a>, <a href="httpcore.html#Http400"><span class="Identifier">Http400</span></a>, <a href="httpcore.html#Http403"><span class="Identifier">Http403</span></a>, <a href="httpcore.html#HttpGet"><span class="Identifier">HttpGet</span></a>, <a href="httpcore.html#Http508"><span class="Identifier">Http508</span></a>, <a href="httpcore.html#Http415"><span class="Identifier">Http415</span></a>, <a href="httpcore.html#HttpHead"><span class="Identifier">HttpHead</span></a>, <a href="httpcore.html#Http412"><span class="Identifier">Http412</span></a>, <a href="httpcore.html#Http103"><span class="Identifier">Http103</span></a>, <a href="httpcore.html#Http405"><span class="Identifier">Http405</span></a>, <a href="httpcore.html#Http303"><span class="Identifier">Http303</span></a>, <a href="httpcore.html#Http204"><span class="Identifier">Http204</span></a>, <a href="httpcore.html#Http424"><span class="Identifier">Http424</span></a>, <a href="httpcore.html#HttpCode"><span class="Identifier">HttpCode</span></a>, <a href="httpcore.html#Http422"><span class="Identifier">Http422</span></a>, <a href="httpcore.html#Http226"><span class="Identifier">Http226</span></a>, <a href="httpcore.html#[],HttpHeaders,string"><span class="Identifier">[]</span></a>
|
|
</dl>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="twelve-columns footer">
|
|
<span class="nim-sprite"></span>
|
|
<br>
|
|
<small style="color: var(--hint);">Made with Nim. Generated: 2025-12-28 15:54:59 UTC</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
|
|
|
</body>
|
|
</html>
|