123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308 |
- <?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/httpclient</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/httpclient</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" id="retrieving-a-website_toc" href="#retrieving-a-website">Retrieving a website</a></li>
- <li><a class="reference" id="using-http-post_toc" href="#using-http-post">Using HTTP POST</a></li>
- <li><a class="reference" id="progress-reporting_toc" href="#progress-reporting">Progress reporting</a></li>
- <li><a class="reference" id="sslslashtls-support_toc" href="#sslslashtls-support">SSL/TLS support</a></li>
- <li><a class="reference" id="timeouts_toc" href="#timeouts">Timeouts</a></li>
- <li><a class="reference" id="proxy_toc" href="#proxy">Proxy</a></li>
- <li><a class="reference" id="redirects_toc" href="#redirects">Redirects</a></li>
- <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="#AsyncHttpClient" title="AsyncHttpClient = HttpClientBase[AsyncSocket]">AsyncHttpClient</a></li>
- <li><a class="reference" href="#AsyncResponse" title="AsyncResponse = ref object
- version*: string
- status*: string
- headers*: HttpHeaders
- bodyStream*: FutureStream[string]">AsyncResponse</a></li>
- <li><a class="reference" href="#HttpClient" title="HttpClient = HttpClientBase[Socket]">HttpClient</a></li>
- <li><a class="reference" href="#HttpClientBase" title="HttpClientBase[SocketType] = ref object
- ## Where we are currently connected.
- headers*: HttpHeaders ## Headers to send in requests.
- ## Maximum redirects, set to `0` to disable.
- timeout*: int ## Only used for blocking HttpClient for now.
- ## `nil` or the callback to call when request progress changes.
- when SocketType is Socket:
- onProgressChanged*: ProgressChangedProc[void]
- else:
- onProgressChanged*: ProgressChangedProc[Future[void]]
- when defined(ssl):
- when SocketType is AsyncSocket:
- else:
- ## When `false`, the body is never read in requestAux.">HttpClientBase</a></li>
- <li><a class="reference" href="#HttpRequestError" title="HttpRequestError = object of IOError">HttpRequestError</a></li>
- <li><a class="reference" href="#MultipartData" title="MultipartData = ref object">MultipartData</a></li>
- <li><a class="reference" href="#MultipartEntries" title="MultipartEntries = openArray[tuple[name, content: string]]">MultipartEntries</a></li>
- <li><a class="reference" href="#ProgressChangedProc" title="ProgressChangedProc[ReturnType] = proc (total, progress, speed: BiggestInt): ReturnType {.
- closure, gcsafe.}">ProgressChangedProc</a></li>
- <li><a class="reference" href="#ProtocolError" title="ProtocolError = object of IOError">ProtocolError</a></li>
- <li><a class="reference" href="#Proxy" title="Proxy = ref object
- url*: Uri
- auth*: string">Proxy</a></li>
- <li><a class="reference" href="#Response" title="Response = ref object
- version*: string
- status*: string
- headers*: HttpHeaders
- bodyStream*: Stream">Response</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="#defUserAgent" title="defUserAgent = "Nim-httpclient/2.3.1"">defUserAgent</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">$
- <li><a class="reference" href="#%24%2CMultipartData" title="`$`(data: MultipartData): string">`$`(data: MultipartData): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">[]=
- <li><a class="reference" href="#%5B%5D%3D%2CMultipartData%2Cstring%2Cstring" title="`[]=`(p: MultipartData; name, content: string)">`[]=`(p: MultipartData; name, content: string)</a></li>
- <li><a class="reference" href="#%5B%5D%3D%2CMultipartData%2Cstring%2Ctuple%5Bstring%2Cstring%2Cstring%5D" title="`[]=`(p: MultipartData; name: string;
- file: tuple[name, contentType, content: string])">`[]=`(p: MultipartData; name: string;
- file: tuple[name, contentType, content: string])</a></li>
- </ul>
- <ul class="simple nested-toc-section">add
- <li><a class="reference" href="#add%2CMultipartData%2Cstring%2Cstring%2Cstring%2Cstring" title="add(p: MultipartData; name, content: string; filename: string = "";
- contentType: string = ""; useStream = true)">add(p: MultipartData; name, content: string; filename: string = "";
- contentType: string = ""; useStream = true)</a></li>
- <li><a class="reference" href="#add%2CMultipartData%2CMultipartEntries" title="add(p: MultipartData; xs: MultipartEntries): MultipartData">add(p: MultipartData; xs: MultipartEntries): MultipartData</a></li>
- </ul>
- <ul class="simple nested-toc-section">addFiles
- <li><a class="reference" href="#addFiles%2CMultipartData%2CopenArray%5Btuple%5Bstring%2Cstring%5D%5D" title="addFiles(p: MultipartData; xs: openArray[tuple[name, file: string]];
- mimeDb = newMimetypes(); useStream = true): MultipartData">addFiles(p: MultipartData; xs: openArray[tuple[name, file: string]];
- mimeDb = newMimetypes(); useStream = true): MultipartData</a></li>
- </ul>
- <ul class="simple nested-toc-section">body
- <li><a class="reference" href="#body%2CAsyncResponse" title="body(response: AsyncResponse): Future[string]">body(response: AsyncResponse): Future[string]</a></li>
- <li><a class="reference" href="#body%2CResponse" title="body(response: Response): string">body(response: Response): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">close
- <li><a class="reference" href="#close" title="close(client: HttpClient | AsyncHttpClient)">close(client: HttpClient | AsyncHttpClient)</a></li>
- </ul>
- <ul class="simple nested-toc-section">code
- <li><a class="reference" href="#code" title="code(response: Response | AsyncResponse): HttpCode">code(response: Response | AsyncResponse): HttpCode</a></li>
- </ul>
- <ul class="simple nested-toc-section">contentLength
- <li><a class="reference" href="#contentLength" title="contentLength(response: Response | AsyncResponse): int">contentLength(response: Response | AsyncResponse): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">contentType
- <li><a class="reference" href="#contentType" title="contentType(response: Response | AsyncResponse): string">contentType(response: Response | AsyncResponse): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">delete
- <li><a class="reference" href="#delete%2CAsyncHttpClient%2C" title="delete(client: AsyncHttpClient; url: Uri | string): Future[AsyncResponse]">delete(client: AsyncHttpClient; url: Uri | string): Future[AsyncResponse]</a></li>
- <li><a class="reference" href="#delete%2CHttpClient%2C" title="delete(client: HttpClient; url: Uri | string): Response">delete(client: HttpClient; url: Uri | string): Response</a></li>
- </ul>
- <ul class="simple nested-toc-section">deleteContent
- <li><a class="reference" href="#deleteContent%2CAsyncHttpClient%2C" title="deleteContent(client: AsyncHttpClient; url: Uri | string): Future[string]">deleteContent(client: AsyncHttpClient; url: Uri | string): Future[string]</a></li>
- <li><a class="reference" href="#deleteContent%2CHttpClient%2C" title="deleteContent(client: HttpClient; url: Uri | string): string">deleteContent(client: HttpClient; url: Uri | string): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">downloadFile
- <li><a class="reference" href="#downloadFile%2CAsyncHttpClient%2C%2Cstring" title="downloadFile(client: AsyncHttpClient; url: Uri | string; filename: string): Future[
- void]">downloadFile(client: AsyncHttpClient; url: Uri | string; filename: string): Future[
- void]</a></li>
- <li><a class="reference" href="#downloadFile%2CHttpClient%2C%2Cstring" title="downloadFile(client: HttpClient; url: Uri | string; filename: string)">downloadFile(client: HttpClient; url: Uri | string; filename: string)</a></li>
- </ul>
- <ul class="simple nested-toc-section">get
- <li><a class="reference" href="#get%2CAsyncHttpClient%2C" title="get(client: AsyncHttpClient; url: Uri | string): Future[AsyncResponse]">get(client: AsyncHttpClient; url: Uri | string): Future[AsyncResponse]</a></li>
- <li><a class="reference" href="#get%2CHttpClient%2C" title="get(client: HttpClient; url: Uri | string): Response">get(client: HttpClient; url: Uri | string): Response</a></li>
- </ul>
- <ul class="simple nested-toc-section">getContent
- <li><a class="reference" href="#getContent%2CAsyncHttpClient%2C" title="getContent(client: AsyncHttpClient; url: Uri | string): Future[string]">getContent(client: AsyncHttpClient; url: Uri | string): Future[string]</a></li>
- <li><a class="reference" href="#getContent%2CHttpClient%2C" title="getContent(client: HttpClient; url: Uri | string): string">getContent(client: HttpClient; url: Uri | string): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">getSocket
- <li><a class="reference" href="#getSocket%2CAsyncHttpClient" title="getSocket(client: AsyncHttpClient): AsyncSocket">getSocket(client: AsyncHttpClient): AsyncSocket</a></li>
- <li><a class="reference" href="#getSocket%2CHttpClient" title="getSocket(client: HttpClient): Socket">getSocket(client: HttpClient): Socket</a></li>
- </ul>
- <ul class="simple nested-toc-section">head
- <li><a class="reference" href="#head%2CAsyncHttpClient%2C" title="head(client: AsyncHttpClient; url: Uri | string): Future[AsyncResponse]">head(client: AsyncHttpClient; url: Uri | string): Future[AsyncResponse]</a></li>
- <li><a class="reference" href="#head%2CHttpClient%2C" title="head(client: HttpClient; url: Uri | string): Response">head(client: HttpClient; url: Uri | string): Response</a></li>
- </ul>
- <ul class="simple nested-toc-section">lastModified
- <li><a class="reference" href="#lastModified" title="lastModified(response: Response | AsyncResponse): DateTime">lastModified(response: Response | AsyncResponse): DateTime</a></li>
- </ul>
- <ul class="simple nested-toc-section">newAsyncHttpClient
- <li><a class="reference" href="#newAsyncHttpClient%2Cint%2CProxy" title="newAsyncHttpClient(userAgent = defUserAgent; maxRedirects = 5;
- sslContext = getDefaultSSL(); proxy: Proxy = nil;
- headers = newHttpHeaders()): AsyncHttpClient">newAsyncHttpClient(userAgent = defUserAgent; maxRedirects = 5;
- sslContext = getDefaultSSL(); proxy: Proxy = nil;
- headers = newHttpHeaders()): AsyncHttpClient</a></li>
- </ul>
- <ul class="simple nested-toc-section">newHttpClient
- <li><a class="reference" href="#newHttpClient%2Cint%2CProxy%2Cint" title="newHttpClient(userAgent = defUserAgent; maxRedirects = 5;
- sslContext = getDefaultSSL(); proxy: Proxy = nil; timeout = -1;
- headers = newHttpHeaders()): HttpClient">newHttpClient(userAgent = defUserAgent; maxRedirects = 5;
- sslContext = getDefaultSSL(); proxy: Proxy = nil; timeout = -1;
- headers = newHttpHeaders()): HttpClient</a></li>
- </ul>
- <ul class="simple nested-toc-section">newMultipartData
- <li><a class="reference" href="#newMultipartData" title="newMultipartData(): MultipartData">newMultipartData(): MultipartData</a></li>
- <li><a class="reference" href="#newMultipartData%2CMultipartEntries" title="newMultipartData(xs: MultipartEntries): MultipartData">newMultipartData(xs: MultipartEntries): MultipartData</a></li>
- </ul>
- <ul class="simple nested-toc-section">newProxy
- <li><a class="reference" href="#newProxy%2Cstring%2Cstring" title="newProxy(url: string; auth = ""): Proxy">newProxy(url: string; auth = ""): Proxy</a></li>
- <li><a class="reference" href="#newProxy%2CUri%2Cstring" title="newProxy(url: Uri; auth = ""): Proxy">newProxy(url: Uri; auth = ""): Proxy</a></li>
- </ul>
- <ul class="simple nested-toc-section">patch
- <li><a class="reference" href="#patch%2CAsyncHttpClient%2C%2Cstring%2CMultipartData" title="patch(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[AsyncResponse]">patch(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[AsyncResponse]</a></li>
- <li><a class="reference" href="#patch%2CHttpClient%2C%2Cstring%2CMultipartData" title="patch(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Response">patch(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Response</a></li>
- </ul>
- <ul class="simple nested-toc-section">patchContent
- <li><a class="reference" href="#patchContent%2CAsyncHttpClient%2C%2Cstring%2CMultipartData" title="patchContent(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[string]">patchContent(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[string]</a></li>
- <li><a class="reference" href="#patchContent%2CHttpClient%2C%2Cstring%2CMultipartData" title="patchContent(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): string">patchContent(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">post
- <li><a class="reference" href="#post%2CAsyncHttpClient%2C%2Cstring%2CMultipartData" title="post(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[AsyncResponse]">post(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[AsyncResponse]</a></li>
- <li><a class="reference" href="#post%2CHttpClient%2C%2Cstring%2CMultipartData" title="post(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Response">post(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Response</a></li>
- </ul>
- <ul class="simple nested-toc-section">postContent
- <li><a class="reference" href="#postContent%2CAsyncHttpClient%2C%2Cstring%2CMultipartData" title="postContent(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[string]">postContent(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[string]</a></li>
- <li><a class="reference" href="#postContent%2CHttpClient%2C%2Cstring%2CMultipartData" title="postContent(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): string">postContent(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">put
- <li><a class="reference" href="#put%2CAsyncHttpClient%2C%2Cstring%2CMultipartData" title="put(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[AsyncResponse]">put(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[AsyncResponse]</a></li>
- <li><a class="reference" href="#put%2CHttpClient%2C%2Cstring%2CMultipartData" title="put(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Response">put(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Response</a></li>
- </ul>
- <ul class="simple nested-toc-section">putContent
- <li><a class="reference" href="#putContent%2CAsyncHttpClient%2C%2Cstring%2CMultipartData" title="putContent(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[string]">putContent(client: AsyncHttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): Future[string]</a></li>
- <li><a class="reference" href="#putContent%2CHttpClient%2C%2Cstring%2CMultipartData" title="putContent(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): string">putContent(client: HttpClient; url: Uri | string; body = "";
- multipart: MultipartData = nil): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">request
- <li><a class="reference" href="#request%2CAsyncHttpClient%2C%2Cstring%2CHttpHeaders%2CMultipartData" title="request(client: AsyncHttpClient; url: Uri | string;
- httpMethod: HttpMethod | string = HttpGet; body = "";
- headers: HttpHeaders = nil; multipart: MultipartData = nil): Future[
- AsyncResponse]">request(client: AsyncHttpClient; url: Uri | string;
- httpMethod: HttpMethod | string = HttpGet; body = "";
- headers: HttpHeaders = nil; multipart: MultipartData = nil): Future[
- AsyncResponse]</a></li>
- <li><a class="reference" href="#request%2CHttpClient%2C%2Cstring%2CHttpHeaders%2CMultipartData" title="request(client: HttpClient; url: Uri | string;
- httpMethod: HttpMethod | string = HttpGet; body = "";
- headers: HttpHeaders = nil; multipart: MultipartData = nil): Response">request(client: HttpClient; url: Uri | string;
- httpMethod: HttpMethod | string = HttpGet; body = "";
- headers: HttpHeaders = nil; multipart: MultipartData = nil): Response</a></li>
- </ul>
- </ul>
- </details>
- </li>
- </ul>
- </div>
- <div class="nine columns" id="content">
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
- <div id="tocRoot"></div>
-
- <p class="module-desc">This module implements a simple HTTP client that can be used to retrieve webpages and other data.<div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
- Validate untrusted inputs: URI parsers and getters are not detecting malicious URIs.</div>
- <h1><a class="toc-backref" id="retrieving-a-website" href="#retrieving-a-website">Retrieving a website</a></h1><p>This example uses HTTP GET to retrieve <tt class="docutils literal"><span class="pre"><span class="Identifier">http</span><span class="Punctuation">:</span><span class="Operator">//</span><span class="Identifier">google</span><span class="Operator">.</span><span class="Identifier">com</span></span></tt>:</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">httpclient</span>
- <span class="Keyword">var</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Keyword">try</span><span class="Punctuation">:</span>
- <span class="Identifier">echo</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">getContent</span><span class="Punctuation">(</span><span class="StringLit">"http://google.com"</span><span class="Punctuation">)</span>
- <span class="Keyword">finally</span><span class="Punctuation">:</span>
- <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
- <p>The same action can also be performed asynchronously, simply use the <tt class="docutils literal"><span class="pre"><span class="Identifier">AsyncHttpClient</span></span></tt>:</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">asyncdispatch</span><span class="Punctuation">,</span> <span class="Identifier">httpclient</span><span class="Punctuation">]</span>
- <span class="Keyword">proc</span> <span class="Identifier">asyncProc</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">string</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">var</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newAsyncHttpClient</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Keyword">try</span><span class="Punctuation">:</span>
- <span class="Keyword">return</span> <span class="Identifier">await</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">getContent</span><span class="Punctuation">(</span><span class="StringLit">"http://google.com"</span><span class="Punctuation">)</span>
- <span class="Keyword">finally</span><span class="Punctuation">:</span>
- <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Identifier">echo</span> <span class="Identifier">waitFor</span> <span class="Identifier">asyncProc</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
- <p>The functionality implemented by <tt class="docutils literal"><span class="pre"><span class="Identifier">HttpClient</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">AsyncHttpClient</span></span></tt> is the same, so you can use whichever one suits you best in the examples shown here.</p>
- <p><strong>Note:</strong> You need to run asynchronous examples in an async proc otherwise you will get an <tt class="docutils literal"><span class="pre"><span class="Identifier">Undeclared</span> <span class="Identifier">identifier</span><span class="Punctuation">:</span> <span class="CharLit">'await'</span></span></tt> error.</p>
- <p><strong>Note:</strong> An asynchronous client instance can only deal with one request at a time. To send multiple requests in parallel, use multiple client instances.</p>
- <h1><a class="toc-backref" id="using-http-post" href="#using-http-post">Using HTTP POST</a></h1><p>This example demonstrates the usage of the W3 HTML Validator, it uses <tt class="docutils literal"><span class="pre"><span class="Identifier">multipart</span><span class="Operator">/</span><span class="Identifier">form</span><span class="Operator">-</span><span class="Identifier">data</span></span></tt> as the <tt class="docutils literal"><span class="pre"><span class="Identifier">Content</span><span class="Operator">-</span><span class="Keyword">Type</span></span></tt> to send the HTML to be validated to the server.</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">httpclient</span><span class="Punctuation">]</span>
- <span class="Keyword">var</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Keyword">var</span> <span class="Identifier">data</span> <span class="Operator">=</span> <span class="Identifier">newMultipartData</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Identifier">data</span><span class="Punctuation">[</span><span class="StringLit">"output"</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="StringLit">"soap12"</span>
- <span class="Identifier">data</span><span class="Punctuation">[</span><span class="StringLit">"uploaded_file"</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Punctuation">(</span><span class="StringLit">"test.html"</span><span class="Punctuation">,</span> <span class="StringLit">"text/html"</span><span class="Punctuation">,</span>
- <span class="StringLit">"<html><head></head><body><p>test</p></body></html>"</span><span class="Punctuation">)</span>
- <span class="Keyword">try</span><span class="Punctuation">:</span>
- <span class="Identifier">echo</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">postContent</span><span class="Punctuation">(</span><span class="StringLit">"http://validator.w3.org/check"</span><span class="Punctuation">,</span> <span class="Identifier">multipart</span><span class="Operator">=</span><span class="Identifier">data</span><span class="Punctuation">)</span>
- <span class="Keyword">finally</span><span class="Punctuation">:</span>
- <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
- <p>To stream files from disk when performing the request, use <tt class="docutils literal"><span class="pre"><span class="Identifier">addFiles</span></span></tt>.</p>
- <p><strong>Note:</strong> This will allocate a new <tt class="docutils literal"><span class="pre"><span class="Identifier">Mimetypes</span></span></tt> database every time you call it, you can pass your own via the <tt class="docutils literal"><span class="pre"><span class="Identifier">mimeDb</span></span></tt> parameter to avoid this.</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">httpclient</span><span class="Punctuation">,</span> <span class="Identifier">mimetypes</span><span class="Punctuation">]</span>
- <span class="Keyword">let</span> <span class="Identifier">mimes</span> <span class="Operator">=</span> <span class="Identifier">newMimetypes</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Keyword">var</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Keyword">var</span> <span class="Identifier">data</span> <span class="Operator">=</span> <span class="Identifier">newMultipartData</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Identifier">data</span><span class="Operator">.</span><span class="Identifier">addFiles</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="StringLit">"uploaded_file"</span><span class="Punctuation">:</span> <span class="StringLit">"test.html"</span><span class="Punctuation">}</span><span class="Punctuation">,</span> <span class="Identifier">mimeDb</span> <span class="Operator">=</span> <span class="Identifier">mimes</span><span class="Punctuation">)</span>
- <span class="Keyword">try</span><span class="Punctuation">:</span>
- <span class="Identifier">echo</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">postContent</span><span class="Punctuation">(</span><span class="StringLit">"http://validator.w3.org/check"</span><span class="Punctuation">,</span> <span class="Identifier">multipart</span><span class="Operator">=</span><span class="Identifier">data</span><span class="Punctuation">)</span>
- <span class="Keyword">finally</span><span class="Punctuation">:</span>
- <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
- <p>You can also make post requests with custom headers. This example sets <tt class="docutils literal"><span class="pre"><span class="Identifier">Content</span><span class="Operator">-</span><span class="Keyword">Type</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">application</span><span class="Operator">/</span><span class="Identifier">json</span></span></tt> and uses a json object for the body</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">httpclient</span><span class="Punctuation">,</span> <span class="Identifier">json</span><span class="Punctuation">]</span>
- <span class="Keyword">let</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Identifier">client</span><span class="Operator">.</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="StringLit">"Content-Type"</span><span class="Punctuation">:</span> <span class="StringLit">"application/json"</span> <span class="Punctuation">}</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">body</span> <span class="Operator">=</span> <span class="Operator">%*</span><span class="Punctuation">{</span>
- <span class="StringLit">"data"</span><span class="Punctuation">:</span> <span class="StringLit">"some text"</span>
- <span class="Punctuation">}</span>
- <span class="Keyword">try</span><span class="Punctuation">:</span>
- <span class="Keyword">let</span> <span class="Identifier">response</span> <span class="Operator">=</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">request</span><span class="Punctuation">(</span><span class="StringLit">"http://some.api"</span><span class="Punctuation">,</span> <span class="Identifier">httpMethod</span> <span class="Operator">=</span> <span class="Identifier">HttpPost</span><span class="Punctuation">,</span> <span class="Identifier">body</span> <span class="Operator">=</span> <span class="Operator">$</span><span class="Identifier">body</span><span class="Punctuation">)</span>
- <span class="Identifier">echo</span> <span class="Identifier">response</span><span class="Operator">.</span><span class="Identifier">status</span>
- <span class="Keyword">finally</span><span class="Punctuation">:</span>
- <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
- <h1><a class="toc-backref" id="progress-reporting" href="#progress-reporting">Progress reporting</a></h1><p>You may specify a callback procedure to be called during an HTTP request. This callback will be executed every second with information about the progress of the HTTP request.</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">asyncdispatch</span><span class="Punctuation">,</span> <span class="Identifier">httpclient</span><span class="Punctuation">]</span>
- <span class="Keyword">proc</span> <span class="Identifier">onProgressChanged</span><span class="Punctuation">(</span><span class="Identifier">total</span><span class="Punctuation">,</span> <span class="Identifier">progress</span><span class="Punctuation">,</span> <span class="Identifier">speed</span><span class="Punctuation">:</span> <span class="Identifier">BiggestInt</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="StringLit">"Downloaded "</span><span class="Punctuation">,</span> <span class="Identifier">progress</span><span class="Punctuation">,</span> <span class="StringLit">" of "</span><span class="Punctuation">,</span> <span class="Identifier">total</span><span class="Punctuation">)</span>
- <span class="Identifier">echo</span><span class="Punctuation">(</span><span class="StringLit">"Current rate: "</span><span class="Punctuation">,</span> <span class="Identifier">speed</span> <span class="Keyword">div</span> <span class="DecNumber">1000</span><span class="Punctuation">,</span> <span class="StringLit">"kb/s"</span><span class="Punctuation">)</span>
- <span class="Keyword">proc</span> <span class="Identifier">asyncProc</span><span class="Punctuation">(</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">var</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newAsyncHttpClient</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">onProgressChanged</span> <span class="Operator">=</span> <span class="Identifier">onProgressChanged</span>
- <span class="Keyword">try</span><span class="Punctuation">:</span>
- <span class="Keyword">discard</span> <span class="Identifier">await</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">getContent</span><span class="Punctuation">(</span><span class="StringLit">"http://speedtest-ams2.digitalocean.com/100mb.test"</span><span class="Punctuation">)</span>
- <span class="Keyword">finally</span><span class="Punctuation">:</span>
- <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Identifier">waitFor</span> <span class="Identifier">asyncProc</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
- <p>If you would like to remove the callback simply set it to <tt class="docutils literal"><span class="pre"><span class="Keyword">nil</span></span></tt>.</p>
- <p><pre class="listing"><span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">onProgressChanged</span> <span class="Operator">=</span> <span class="Keyword">nil</span></pre></p>
- <div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
- The <tt class="docutils literal"><span class="pre"><span class="Identifier">total</span></span></tt> reported by httpclient may be 0 in some cases.</div>
- <h1><a class="toc-backref" id="sslslashtls-support" href="#sslslashtls-support">SSL/TLS support</a></h1><p>This requires the OpenSSL library. Fortunately it's widely used and installed on many operating systems. httpclient will use SSL automatically if you give any of the functions a url with the <tt class="docutils literal"><span class="pre"><span class="Identifier">https</span></span></tt> schema, for example: <tt class="docutils literal"><span class="pre"><span class="Identifier">https</span><span class="Punctuation">:</span><span class="Operator">//</span><span class="Identifier">github</span><span class="Operator">.</span><span class="Identifier">com</span><span class="Operator">/</span></span></tt>.</p>
- <p>You will also have to compile with <tt class="docutils literal"><span class="pre"><span class="Identifier">ssl</span></span></tt> defined like so: <tt class="docutils literal"><span class="pre"><span class="Identifier">nim</span> <span class="Identifier">c</span> <span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">ssl</span> <span class="Operator">...</span></span></tt>.</p>
- <p>Certificate validation is performed by default.</p>
- <p>A set of directories and files from the <a class="reference external" href="ssl_certs.html">ssl_certs</a> module are scanned to locate CA certificates.</p>
- <p>Example of setting SSL verification parameters in a new client:</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">net</span><span class="Punctuation">,</span> <span class="Identifier">httpclient</span><span class="Punctuation">]</span>
- <span class="Keyword">var</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Identifier">sslContext</span><span class="Operator">=</span><span class="Identifier">newContext</span><span class="Punctuation">(</span><span class="Identifier">verifyMode</span><span class="Operator">=</span><span class="Identifier">CVerifyPeer</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
- <p>There are three options for verify mode:</p>
- <ul class="simple"><li><tt class="docutils literal"><span class="pre">CVerifyNone</span></tt>: certificates are not verified;</li>
- <li><tt class="docutils literal"><span class="pre">CVerifyPeer</span></tt>: certificates are verified;</li>
- <li><tt class="docutils literal"><span class="pre">CVerifyPeerUseEnvVars</span></tt>: certificates are verified and the optional environment variables SSL_CERT_FILE and SSL_CERT_DIR are also used to locate certificates</li>
- </ul>
- <p>See <a class="reference external" href="net.html#newContext.string,string,string,string">newContext</a> to tweak or disable certificate validation.</p>
- <h1><a class="toc-backref" id="timeouts" href="#timeouts">Timeouts</a></h1><p>Currently only the synchronous functions support a timeout. The timeout is measured in milliseconds, once it is set any call on a socket which may block will be susceptible to this timeout.</p>
- <p>It may be surprising but the function as a whole can take longer than the specified timeout, only individual internal calls on the socket are affected. In practice this means that as long as the server is sending data an exception will not be raised, if however data does not reach the client within the specified timeout a <tt class="docutils literal"><span class="pre"><span class="Identifier">TimeoutError</span></span></tt> exception will be raised.</p>
- <p>Here is how to set a timeout when creating an <tt class="docutils literal"><span class="pre"><span class="Identifier">HttpClient</span></span></tt> instance:</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">httpclient</span>
- <span class="Keyword">let</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Identifier">timeout</span> <span class="Operator">=</span> <span class="DecNumber">42</span><span class="Punctuation">)</span></pre></p>
- <h1><a class="toc-backref" id="proxy" href="#proxy">Proxy</a></h1><p>A proxy can be specified as a param to any of the procedures defined in this module. To do this, use the <tt class="docutils literal"><span class="pre"><span class="Identifier">newProxy</span></span></tt> constructor. Unfortunately, only basic authentication is supported at the moment.</p>
- <p>Some examples on how to configure a Proxy for <tt class="docutils literal"><span class="pre"><span class="Identifier">HttpClient</span></span></tt>:</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">httpclient</span>
- <span class="Keyword">let</span> <span class="Identifier">myProxy</span> <span class="Operator">=</span> <span class="Identifier">newProxy</span><span class="Punctuation">(</span><span class="StringLit">"http://myproxy.network"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Identifier">proxy</span> <span class="Operator">=</span> <span class="Identifier">myProxy</span><span class="Punctuation">)</span></pre></p>
- <p>Use proxies with basic authentication:</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">httpclient</span>
- <span class="Keyword">let</span> <span class="Identifier">myProxy</span> <span class="Operator">=</span> <span class="Identifier">newProxy</span><span class="Punctuation">(</span><span class="StringLit">"http://myproxy.network"</span><span class="Punctuation">,</span> <span class="Identifier">auth</span><span class="Operator">=</span><span class="StringLit">"user:password"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Identifier">proxy</span> <span class="Operator">=</span> <span class="Identifier">myProxy</span><span class="Punctuation">)</span></pre></p>
- <p>Get Proxy URL from environment variables:</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">httpclient</span>
- <span class="Keyword">var</span> <span class="Identifier">url</span> <span class="Operator">=</span> <span class="StringLit">""</span>
- <span class="Keyword">try</span><span class="Punctuation">:</span>
- <span class="Keyword">if</span> <span class="Identifier">existsEnv</span><span class="Punctuation">(</span><span class="StringLit">"http_proxy"</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
- <span class="Identifier">url</span> <span class="Operator">=</span> <span class="Identifier">getEnv</span><span class="Punctuation">(</span><span class="StringLit">"http_proxy"</span><span class="Punctuation">)</span>
- <span class="Keyword">elif</span> <span class="Identifier">existsEnv</span><span class="Punctuation">(</span><span class="StringLit">"https_proxy"</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
- <span class="Identifier">url</span> <span class="Operator">=</span> <span class="Identifier">getEnv</span><span class="Punctuation">(</span><span class="StringLit">"https_proxy"</span><span class="Punctuation">)</span>
- <span class="Keyword">except</span> <span class="Identifier">ValueError</span><span class="Punctuation">:</span>
- <span class="Identifier">echo</span> <span class="StringLit">"Unable to parse proxy from environment variables."</span>
- <span class="Keyword">let</span> <span class="Identifier">myProxy</span> <span class="Operator">=</span> <span class="Identifier">newProxy</span><span class="Punctuation">(</span><span class="Identifier">url</span> <span class="Operator">=</span> <span class="Identifier">url</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Identifier">proxy</span> <span class="Operator">=</span> <span class="Identifier">myProxy</span><span class="Punctuation">)</span></pre></p>
- <h1><a class="toc-backref" id="redirects" href="#redirects">Redirects</a></h1><p>The maximum redirects can be set with the <tt class="docutils literal"><span class="pre"><span class="Identifier">maxRedirects</span></span></tt> of <tt class="docutils literal"><span class="pre"><span class="Identifier">int</span></span></tt> type, it specifies the maximum amount of redirects to follow, it defaults to <tt class="docutils literal"><span class="pre"><span class="DecNumber">5</span></span></tt>, you can set it to <tt class="docutils literal"><span class="pre"><span class="DecNumber">0</span></span></tt> to disable redirects.</p>
- <p>Here you can see an example about how to set the <tt class="docutils literal"><span class="pre"><span class="Identifier">maxRedirects</span></span></tt> of <tt class="docutils literal"><span class="pre"><span class="Identifier">HttpClient</span></span></tt>:</p>
- <p><pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">httpclient</span>
- <span class="Keyword">let</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Identifier">maxRedirects</span> <span class="Operator">=</span> <span class="DecNumber">0</span><span class="Punctuation">)</span></pre></p>
- </p>
- <div class="section" id="6">
- <h1><a class="toc-backref" href="#6">Imports</a></h1>
- <dl class="item">
- <a class="reference external" href="since.html">since</a>, <a class="reference external" href="net.html">net</a>, <a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="uri.html">uri</a>, <a class="reference external" href="parseutils.html">parseutils</a>, <a class="reference external" href="base64.html">base64</a>, <a class="reference external" href="os.html">os</a>, <a class="reference external" href="mimetypes.html">mimetypes</a>, <a class="reference external" href="math.html">math</a>, <a class="reference external" href="random.html">random</a>, <a class="reference external" href="httpcore.html">httpcore</a>, <a class="reference external" href="times.html">times</a>, <a class="reference external" href="tables.html">tables</a>, <a class="reference external" href="streams.html">streams</a>, <a class="reference external" href="monotimes.html">monotimes</a>, <a class="reference external" href="asyncnet.html">asyncnet</a>, <a class="reference external" href="asyncdispatch.html">asyncdispatch</a>, <a class="reference external" href="asyncfile.html">asyncfile</a>, <a class="reference external" href="nativesockets.html">nativesockets</a>, <a class="reference external" href="assertions.html">assertions</a>, <a class="reference external" href="syncio.html">syncio</a>
- </dl>
- </div>
- <div class="section" id="7">
- <h1><a class="toc-backref" href="#7">Types</a></h1>
- <dl class="item">
- <div id="AsyncHttpClient">
- <dt><pre><a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a> <span class="Other">=</span> <a href="httpclient.html#HttpClientBase"><span class="Identifier">HttpClientBase</span></a><span class="Other">[</span><a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">]</span></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L663" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L663" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="AsyncResponse">
- <dt><pre><a href="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span>
- <span class="Identifier">version</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a>
- <span class="Identifier">status</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</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">bodyStream</span><span class="Operator">*</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L282" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L282" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="HttpClient">
- <dt><pre><a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a> <span class="Other">=</span> <a href="httpclient.html#HttpClientBase"><span class="Identifier">HttpClientBase</span></a><span class="Other">[</span><a href="net.html#Socket"><span class="Identifier">Socket</span></a><span class="Other">]</span></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L620" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L620" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="HttpClientBase">
- <dt><pre><a href="httpclient.html#HttpClientBase"><span class="Identifier">HttpClientBase</span></a><span class="Other">[</span><span class="Identifier">SocketType</span><span class="Other">]</span> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span>
- <span class="Comment">## Where we are currently connected.</span>
- <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="Comment">## Headers to send in requests.</span>
- <span class="Comment">## Maximum redirects, set to `0` to disable.</span>
- <span class="Identifier">timeout</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> <span class="Comment">## Only used for blocking HttpClient for now.</span>
- <span class="Comment">## `nil` or the callback to call when request progress changes.</span>
- <span class="Keyword">when</span> <span class="Identifier">SocketType</span> <span class="Keyword">is</span> <span class="Identifier">Socket</span><span class="Other">:</span>
- <span class="Identifier">onProgressChanged</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">ProgressChangedProc</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span>
- <span class="Keyword">else</span><span class="Other">:</span>
- <span class="Identifier">onProgressChanged</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">ProgressChangedProc</span><span class="Other">[</span><span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">]</span>
- <span class="Keyword">when</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">ssl</span><span class="Other">)</span><span class="Other">:</span>
- <span class="Keyword">when</span> <span class="Identifier">SocketType</span> <span class="Keyword">is</span> <span class="Identifier">AsyncSocket</span><span class="Other">:</span>
- <span class="Keyword">else</span><span class="Other">:</span>
- <span class="Comment">## When `false`, the body is never read in requestAux.</span></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L592" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L592" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="HttpRequestError">
- <dt><pre><a href="httpclient.html#HttpRequestError"><span class="Identifier">HttpRequestError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="exceptions.html#IOError"><span class="Identifier">IOError</span></a></pre></dt>
- <dd>
-
- Thrown in the <tt class="docutils literal"><span class="pre"><span class="Identifier">getContent</span></span></tt> proc and <tt class="docutils literal"><span class="pre"><span class="Identifier">postContent</span></span></tt> proc, when the server returns an error
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L360" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L360" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="MultipartData">
- <dt><pre><a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</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/httpclient.nim#L353" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L353" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="MultipartEntries">
- <dt><pre><a href="httpclient.html#MultipartEntries"><span class="Identifier">MultipartEntries</span></a> <span class="Other">=</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">name</span><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="Other">]</span></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L352" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L352" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="ProgressChangedProc">
- <dt><pre><a href="httpclient.html#ProgressChangedProc"><span class="Identifier">ProgressChangedProc</span></a><span class="Other">[</span><span class="Identifier">ReturnType</span><span class="Other">]</span> <span class="Other">=</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">total</span><span class="Other">,</span> <span class="Identifier">progress</span><span class="Other">,</span> <span class="Identifier">speed</span><span class="Other">:</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">ReturnType</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>.}</pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L588" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L588" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="ProtocolError">
- <dt><pre><a href="httpclient.html#ProtocolError"><span class="Identifier">ProtocolError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="exceptions.html#IOError"><span class="Identifier">IOError</span></a></pre></dt>
- <dd>
-
- exception that is raised when server does not conform to the implemented protocol
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L356" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L356" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="Proxy">
- <dt><pre><a href="httpclient.html#Proxy"><span class="Identifier">Proxy</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</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">auth</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/httpclient.nim#L339" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L339" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="Response">
- <dt><pre><a href="httpclient.html#Response"><span class="Identifier">Response</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span>
- <span class="Identifier">version</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a>
- <span class="Identifier">status</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</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">bodyStream</span><span class="Operator">*</span><span class="Other">:</span> <a href="streams.html#Stream"><span class="Identifier">Stream</span></a></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L275" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L275" 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="defUserAgent">
- <dt><pre><a href="httpclient.html#defUserAgent"><span class="Identifier">defUserAgent</span></a> <span class="Other">=</span> <span class="StringLit">"Nim-httpclient/2.3.1"</span></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L364" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L364" 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="$-procs-all">
- <div id="$,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#%24%2CMultipartData"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</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>
-
- convert MultipartData to string so it's human readable when echo see <a class="reference external" href="https://github.com/nim-lang/Nim/issues/11863">https://github.com/nim-lang/Nim/issues/11863</a>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L402" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L402" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="[]=-procs-all">
- <div id="[]=,MultipartData,string,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%3D%2CMultipartData%2Cstring%2Cstring"><span class="Identifier">`[]=`</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a><span class="Other">;</span> <span class="Identifier">name</span><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">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="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="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>Add a multipart entry to the multipart data <tt class="docutils literal"><span class="pre"><span class="Identifier">p</span></span></tt>. The value is added without a filename and without a content type.</p>
- <p><pre class="listing"><span class="Identifier">data</span><span class="Punctuation">[</span><span class="StringLit">"username"</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="StringLit">"NimUser"</span></pre></p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L488" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L488" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="[]=,MultipartData,string,tuple[string,string,string]">
- <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%3D%2CMultipartData%2Cstring%2Ctuple%5Bstring%2Cstring%2Cstring%5D"><span class="Identifier">`[]=`</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a><span class="Other">;</span> <span class="Identifier">name</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span>
- <span class="Identifier">file</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">contentType</span><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="Other">)</span> {.<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="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="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>Add a file to the multipart data <tt class="docutils literal"><span class="pre"><span class="Identifier">p</span></span></tt>, specifying filename, contentType and content manually.</p>
- <p><pre class="listing"><span class="Identifier">data</span><span class="Punctuation">[</span><span class="StringLit">"uploaded_file"</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Punctuation">(</span><span class="StringLit">"test.html"</span><span class="Punctuation">,</span> <span class="StringLit">"text/html"</span><span class="Punctuation">,</span>
- <span class="StringLit">"<html><head></head><body><p>test</p></body></html>"</span><span class="Punctuation">)</span></pre></p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L497" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L497" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="add-procs-all">
- <div id="add,MultipartData,string,string,string,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#add%2CMultipartData%2Cstring%2Cstring%2Cstring%2Cstring"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a><span class="Other">;</span> <span class="Identifier">name</span><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">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">contentType</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">useStream</span> <span class="Other">=</span> <span class="Identifier">true</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">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="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>Add a value to the multipart data.</p>
- <p>When <tt class="docutils literal"><span class="pre"><span class="Identifier">useStream</span></span></tt> is <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt>, the file will be read into memory.</p>
- <p>Raises a <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> exception if <tt class="docutils literal"><span class="pre"><span class="Identifier">name</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">contentType</span></span></tt> contain newline characters.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L415" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L415" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="add,MultipartData,MultipartEntries">
- <dt><pre><span class="Keyword">proc</span> <a href="#add%2CMultipartData%2CMultipartEntries"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a><span class="Other">;</span> <span class="Identifier">xs</span><span class="Other">:</span> <a href="httpclient.html#MultipartEntries"><span class="Identifier">MultipartEntries</span></a><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a> {.<span class="Identifier">discardable</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">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="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>Add a list of multipart entries to the multipart data <tt class="docutils literal"><span class="pre"><span class="Identifier">p</span></span></tt>. All values are added without a filename and without a content type.</p>
- <p><pre class="listing"><span class="Identifier">data</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="StringLit">"action"</span><span class="Punctuation">:</span> <span class="StringLit">"login"</span><span class="Punctuation">,</span> <span class="StringLit">"format"</span><span class="Punctuation">:</span> <span class="StringLit">"json"</span><span class="Punctuation">}</span><span class="Punctuation">)</span></pre></p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L443" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L443" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="addFiles-procs-all">
- <div id="addFiles,MultipartData,openArray[tuple[string,string]]">
- <dt><pre><span class="Keyword">proc</span> <a href="#addFiles%2CMultipartData%2CopenArray%5Btuple%5Bstring%2Cstring%5D%5D"><span class="Identifier">addFiles</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a><span class="Other">;</span> <span class="Identifier">xs</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">file</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">]</span><span class="Other">;</span>
- <span class="Identifier">mimeDb</span> <span class="Other">=</span> <span class="Identifier">newMimetypes</span><span class="Other">(</span><span class="Other">)</span><span class="Other">;</span> <span class="Identifier">useStream</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a> {.
- <span class="Identifier">discardable</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">IOError</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">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>
-
- <p>Add files to a multipart data object. The files will be streamed from disk when the request is being made. When <tt class="docutils literal"><span class="pre"><span class="Identifier">stream</span></span></tt> is <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt>, the files are instead read into memory, but beware this is very memory ineffecient even for small files. The MIME types will automatically be determined. Raises an <tt class="docutils literal"><span class="pre"><span class="Identifier">IOError</span></span></tt> if the file cannot be opened or reading fails. To manually specify file content, filename and MIME type, use <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Punctuation">]</span><span class="Operator">=</span></span></tt> instead.</p>
- <p><pre class="listing"><span class="Identifier">data</span><span class="Operator">.</span><span class="Identifier">addFiles</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="StringLit">"uploaded_file"</span><span class="Punctuation">:</span> <span class="StringLit">"public/test.html"</span><span class="Punctuation">}</span><span class="Punctuation">)</span></pre></p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L466" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L466" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="body-procs-all">
- <div id="body,AsyncResponse">
- <dt><pre><span class="Keyword">proc</span> <a href="#body%2CAsyncResponse"><span class="Identifier">body</span></a><span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <a href="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</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#string"><span class="Identifier">string</span></a><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="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>
-
- Reads the response's body and caches it. The read is performed only once.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L331" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L331" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="body,Response">
- <dt><pre><span class="Keyword">proc</span> <a href="#body%2CResponse"><span class="Identifier">body</span></a><span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</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">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</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">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>
-
- <p>Retrieves the specified response's body.</p>
- <p>The response's body stream is read synchronously.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L323" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L323" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="close-procs-all">
- <div id="close">
- <dt><pre><span class="Keyword">proc</span> <a href="#close"><span class="Identifier">close</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a> <span class="Operator">|</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">)</span></pre></dt>
- <dd>
-
- Closes any connections held by the HTTP client.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L705" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L705" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="code-procs-all">
- <div id="code">
- <dt><pre><span class="Keyword">proc</span> <a href="#code"><span class="Identifier">code</span></a><span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a> <span class="Operator">|</span> <a href="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><span class="Other">)</span><span class="Other">:</span> <a href="httpcore.html#HttpCode"><span class="Identifier">HttpCode</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><a href="exceptions.html#ValueError"><span class="Identifier">ValueError</span></a><span class="Other">,</span> <a href="exceptions.html#OverflowDefect"><span class="Identifier">OverflowDefect</span></a><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <p>Retrieves the specified response's <tt class="docutils literal"><span class="pre"><span class="Identifier">HttpCode</span></span></tt>.</p>
- <p>Raises a <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> if the response's <tt class="docutils literal"><span class="pre"><span class="Identifier">status</span></span></tt> does not have a corresponding <tt class="docutils literal"><span class="pre"><span class="Identifier">HttpCode</span></span></tt>.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L289" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L289" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="contentLength-procs-all">
- <div id="contentLength">
- <dt><pre><span class="Keyword">proc</span> <a href="#contentLength"><span class="Identifier">contentLength</span></a><span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a> <span class="Operator">|</span> <a href="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a></pre></dt>
- <dd>
-
- <p>Retrieves the specified response's content length.</p>
- <p>This is effectively the value of the "Content-Length" header.</p>
- <p>A <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> exception will be raised if the value is not an integer. If the Content-Length header is not set in the response, ContentLength is set to the value -1.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L303" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L303" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="contentType-procs-all">
- <div id="contentType">
- <dt><pre><span class="Keyword">proc</span> <a href="#contentType"><span class="Identifier">contentType</span></a><span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a> <span class="Operator">|</span> <a href="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
- <dd>
-
- <p>Retrieves the specified response's content type.</p>
- <p>This is effectively the value of the "Content-Type" header.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L297" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L297" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="delete-procs-all">
- <div id="delete,AsyncHttpClient,">
- <dt><pre><span class="Keyword">proc</span> <a href="#delete%2CAsyncHttpClient%2C"><span class="Identifier">delete</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</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="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><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>.}</pre></dt>
- <dd>
-
- Connects to the hostname specified by the URL and performs a DELETE request. This procedure uses httpClient values such as <tt class="docutils literal"><span class="pre"><span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">maxRedirects</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1263" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1263" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="delete,HttpClient,">
- <dt><pre><span class="Keyword">proc</span> <a href="#delete%2CHttpClient%2C"><span class="Identifier">delete</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1264" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1264" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="deleteContent-procs-all">
- <div id="deleteContent,AsyncHttpClient,">
- <dt><pre><span class="Keyword">proc</span> <a href="#deleteContent%2CAsyncHttpClient%2C"><span class="Identifier">deleteContent</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</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#string"><span class="Identifier">string</span></a><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>.}</pre></dt>
- <dd>
-
- Connects to the hostname specified by the URL and returns the content of a DELETE request.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1269" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1269" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="deleteContent,HttpClient,">
- <dt><pre><span class="Keyword">proc</span> <a href="#deleteContent%2CHttpClient%2C"><span class="Identifier">deleteContent</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</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/httpclient.nim#L1270" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1270" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="downloadFile-procs-all">
- <div id="downloadFile,AsyncHttpClient,,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#downloadFile%2CAsyncHttpClient%2C%2Cstring"><span class="Identifier">downloadFile</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</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></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1354" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1354" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="downloadFile,HttpClient,,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#downloadFile%2CHttpClient%2C%2Cstring"><span class="Identifier">downloadFile</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span></pre></dt>
- <dd>
-
- Downloads <tt class="docutils literal"><span class="pre"><span class="Identifier">url</span></span></tt> and saves it to <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1316" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1316" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="get-procs-all">
- <div id="get,AsyncHttpClient,">
- <dt><pre><span class="Keyword">proc</span> <a href="#get%2CAsyncHttpClient%2C"><span class="Identifier">get</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</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="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><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>.}</pre></dt>
- <dd>
-
- <p>Connects to the hostname specified by the URL and performs a GET request.</p>
- <p>This procedure uses httpClient values such as <tt class="docutils literal"><span class="pre"><span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">maxRedirects</span></span></tt>.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1250" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1250" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="get,HttpClient,">
- <dt><pre><span class="Keyword">proc</span> <a href="#get%2CHttpClient%2C"><span class="Identifier">get</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1251" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1251" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="getContent-procs-all">
- <div id="getContent,AsyncHttpClient,">
- <dt><pre><span class="Keyword">proc</span> <a href="#getContent%2CAsyncHttpClient%2C"><span class="Identifier">getContent</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</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#string"><span class="Identifier">string</span></a><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>.}</pre></dt>
- <dd>
-
- Connects to the hostname specified by the URL and returns the content of a GET request.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1257" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1257" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="getContent,HttpClient,">
- <dt><pre><span class="Keyword">proc</span> <a href="#getContent%2CHttpClient%2C"><span class="Identifier">getContent</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</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/httpclient.nim#L1258" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1258" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="getSocket-procs-all">
- <div id="getSocket,AsyncHttpClient">
- <dt><pre><span class="Keyword">proc</span> <a href="#getSocket%2CAsyncHttpClient"><span class="Identifier">getSocket</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</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>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L723" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L723" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="getSocket,HttpClient">
- <dt><pre><span class="Keyword">proc</span> <a href="#getSocket%2CHttpClient"><span class="Identifier">getSocket</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">)</span><span class="Other">:</span> <a href="net.html#Socket"><span class="Identifier">Socket</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>
-
- <p>Get network socket, useful if you want to find out more details about the connection.</p>
- <p>This example shows info about local and remote endpoints:</p>
- <p><pre class="listing"><span class="Keyword">if</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">connected</span><span class="Punctuation">:</span>
- <span class="Identifier">echo</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">getSocket</span><span class="Operator">.</span><span class="Identifier">getLocalAddr</span>
- <span class="Identifier">echo</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">getSocket</span><span class="Operator">.</span><span class="Identifier">getPeerAddr</span></pre></p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L711" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L711" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="head-procs-all">
- <div id="head,AsyncHttpClient,">
- <dt><pre><span class="Keyword">proc</span> <a href="#head%2CAsyncHttpClient%2C"><span class="Identifier">head</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</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="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><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>.}</pre></dt>
- <dd>
-
- <p>Connects to the hostname specified by the URL and performs a HEAD request.</p>
- <p>This procedure uses httpClient values such as <tt class="docutils literal"><span class="pre"><span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">maxRedirects</span></span></tt>.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1243" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1243" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="head,HttpClient,">
- <dt><pre><span class="Keyword">proc</span> <a href="#head%2CHttpClient%2C"><span class="Identifier">head</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1244" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1244" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="lastModified-procs-all">
- <div id="lastModified">
- <dt><pre><span class="Keyword">proc</span> <a href="#lastModified"><span class="Identifier">lastModified</span></a><span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a> <span class="Operator">|</span> <a href="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><span class="Other">)</span><span class="Other">:</span> <a href="times.html#DateTime"><span class="Identifier">DateTime</span></a></pre></dt>
- <dd>
-
- <p>Retrieves the specified response's last modified time.</p>
- <p>This is effectively the value of the "Last-Modified" header.</p>
- <p>Raises a <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> if the parsing fails or the value is not a correctly formatted time.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L313" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L313" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newAsyncHttpClient-procs-all">
- <div id="newAsyncHttpClient,int,Proxy">
- <dt><pre><span class="Keyword">proc</span> <a href="#newAsyncHttpClient%2Cint%2CProxy"><span class="Identifier">newAsyncHttpClient</span></a><span class="Other">(</span><span class="Identifier">userAgent</span> <span class="Other">=</span> <span class="Identifier">defUserAgent</span><span class="Other">;</span> <span class="Identifier">maxRedirects</span> <span class="Other">=</span> <span class="DecNumber">5</span><span class="Other">;</span>
- <span class="Identifier">sslContext</span> <span class="Other">=</span> <span class="Identifier">getDefaultSSL</span><span class="Other">(</span><span class="Other">)</span><span class="Other">;</span> <span class="Identifier">proxy</span><span class="Other">:</span> <a href="httpclient.html#Proxy"><span class="Identifier">Proxy</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">;</span>
- <span class="Identifier">headers</span> <span class="Other">=</span> <span class="Identifier">newHttpHeaders</span><span class="Other">(</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</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>
-
- <p>Creates a new AsyncHttpClient instance.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">userAgent</span></span></tt> specifies the user agent that will be used when making requests.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">maxRedirects</span></span></tt> specifies the maximum amount of redirects to follow, default is 5.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">sslContext</span></span></tt> specifies the SSL context to use for HTTPS requests.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">proxy</span></span></tt> specifies an HTTP proxy to use for this HTTP client's connections.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">headers</span></span></tt> specifies the HTTP Headers.</p>
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">asyncdispatch</span><span class="Punctuation">,</span> <span class="Identifier">strutils</span><span class="Punctuation">]</span>
- <span class="Keyword">proc</span> <span class="Identifier">asyncProc</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">string</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">let</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">newAsyncHttpClient</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">await</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">getContent</span><span class="Punctuation">(</span><span class="StringLit">"http://example.com"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">exampleHtml</span> <span class="Operator">=</span> <span class="Identifier">waitFor</span> <span class="Identifier">asyncProc</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="StringLit">"Example Domain"</span> <span class="Keyword">in</span> <span class="Identifier">exampleHtml</span>
- <span class="Identifier">assert</span> <span class="StringLit">"Pizza"</span> <span class="Keyword">notin</span> <span class="Identifier">exampleHtml</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L665" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L665" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newHttpClient-procs-all">
- <div id="newHttpClient,int,Proxy,int">
- <dt><pre><span class="Keyword">proc</span> <a href="#newHttpClient%2Cint%2CProxy%2Cint"><span class="Identifier">newHttpClient</span></a><span class="Other">(</span><span class="Identifier">userAgent</span> <span class="Other">=</span> <span class="Identifier">defUserAgent</span><span class="Other">;</span> <span class="Identifier">maxRedirects</span> <span class="Other">=</span> <span class="DecNumber">5</span><span class="Other">;</span>
- <span class="Identifier">sslContext</span> <span class="Other">=</span> <span class="Identifier">getDefaultSSL</span><span class="Other">(</span><span class="Other">)</span><span class="Other">;</span> <span class="Identifier">proxy</span><span class="Other">:</span> <a href="httpclient.html#Proxy"><span class="Identifier">Proxy</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">;</span>
- <span class="Identifier">timeout</span> <span class="Other">=</span> <span class="DecNumber">-1</span><span class="Other">;</span> <span class="Identifier">headers</span> <span class="Other">=</span> <span class="Identifier">newHttpHeaders</span><span class="Other">(</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</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>
-
- <p>Creates a new HttpClient instance.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">userAgent</span></span></tt> specifies the user agent that will be used when making requests.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">maxRedirects</span></span></tt> specifies the maximum amount of redirects to follow, default is 5.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">sslContext</span></span></tt> specifies the SSL context to use for HTTPS requests. See <a class="reference external" href="#sslslashtls-support">SSL/TLS support</a></p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">proxy</span></span></tt> specifies an HTTP proxy to use for this HTTP client's connections.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">timeout</span></span></tt> specifies the number of milliseconds to allow before a <tt class="docutils literal"><span class="pre"><span class="Identifier">TimeoutError</span></span></tt> is raised.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">headers</span></span></tt> specifies the HTTP Headers.</p>
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">strutils</span>
- <span class="Keyword">let</span> <span class="Identifier">exampleHtml</span> <span class="Operator">=</span> <span class="Identifier">newHttpClient</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">getContent</span><span class="Punctuation">(</span><span class="StringLit">"http://example.com"</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="StringLit">"Example Domain"</span> <span class="Keyword">in</span> <span class="Identifier">exampleHtml</span>
- <span class="Identifier">assert</span> <span class="StringLit">"Pizza"</span> <span class="Keyword">notin</span> <span class="Identifier">exampleHtml</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L622" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L622" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newMultipartData-procs-all">
- <div id="newMultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#newMultipartData"><span class="Identifier">newMultipartData</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</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>
-
- Constructs a new <tt class="docutils literal"><span class="pre"><span class="Identifier">MultipartData</span></span></tt> object.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L398" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L398" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="newMultipartData,MultipartEntries">
- <dt><pre><span class="Keyword">proc</span> <a href="#newMultipartData%2CMultipartEntries"><span class="Identifier">newMultipartData</span></a><span class="Other">(</span><span class="Identifier">xs</span><span class="Other">:</span> <a href="httpclient.html#MultipartEntries"><span class="Identifier">MultipartEntries</span></a><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</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">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="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>Create a new multipart data object and fill it with the entries <tt class="docutils literal"><span class="pre"><span class="Identifier">xs</span></span></tt> directly.</p>
- <p><pre class="listing"><span class="Keyword">var</span> <span class="Identifier">data</span> <span class="Operator">=</span> <span class="Identifier">newMultipartData</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="StringLit">"action"</span><span class="Punctuation">:</span> <span class="StringLit">"login"</span><span class="Punctuation">,</span> <span class="StringLit">"format"</span><span class="Punctuation">:</span> <span class="StringLit">"json"</span><span class="Punctuation">}</span><span class="Punctuation">)</span></pre></p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L455" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L455" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newProxy-procs-all">
- <div id="newProxy,string,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#newProxy%2Cstring%2Cstring"><span class="Identifier">newProxy</span></a><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">auth</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#Proxy"><span class="Identifier">Proxy</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>
-
- Constructs a new <tt class="docutils literal"><span class="pre"><span class="Identifier">TProxy</span></span></tt> object.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L390" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L390" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="newProxy,Uri,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#newProxy%2CUri%2Cstring"><span class="Identifier">newProxy</span></a><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a><span class="Other">;</span> <span class="Identifier">auth</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#Proxy"><span class="Identifier">Proxy</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>
-
- Constructs a new <tt class="docutils literal"><span class="pre"><span class="Identifier">TProxy</span></span></tt> object.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L394" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L394" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="patch-procs-all">
- <div id="patch,AsyncHttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#patch%2CAsyncHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">patch</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</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="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><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>.}</pre></dt>
- <dd>
-
- Connects to the hostname specified by the URL and performs a PATCH request. This procedure uses httpClient values such as <tt class="docutils literal"><span class="pre"><span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">maxRedirects</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1302" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1302" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="patch,HttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#patch%2CHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">patch</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1304" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1304" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="patchContent-procs-all">
- <div id="patchContent,AsyncHttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#patchContent%2CAsyncHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">patchContent</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</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#string"><span class="Identifier">string</span></a><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>.}</pre></dt>
- <dd>
-
- Connects to the hostname specified by the URL and returns the content of a PATCH request.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1309" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1309" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="patchContent,HttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#patchContent%2CHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">patchContent</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</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/httpclient.nim#L1311" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1311" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="post-procs-all">
- <div id="post,AsyncHttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#post%2CAsyncHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">post</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</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="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><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>.}</pre></dt>
- <dd>
-
- Connects to the hostname specified by the URL and performs a POST request. This procedure uses httpClient values such as <tt class="docutils literal"><span class="pre"><span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">maxRedirects</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1275" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1275" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="post,HttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#post%2CHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">post</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1277" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1277" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="postContent-procs-all">
- <div id="postContent,AsyncHttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#postContent%2CAsyncHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">postContent</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</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#string"><span class="Identifier">string</span></a><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>.}</pre></dt>
- <dd>
-
- Connects to the hostname specified by the URL and returns the content of a POST request.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1282" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1282" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="postContent,HttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#postContent%2CHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">postContent</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</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/httpclient.nim#L1284" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1284" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="put-procs-all">
- <div id="put,AsyncHttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#put%2CAsyncHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">put</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</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="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><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>.}</pre></dt>
- <dd>
-
- Connects to the hostname specified by the URL and performs a PUT request. This procedure uses httpClient values such as <tt class="docutils literal"><span class="pre"><span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">maxRedirects</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1289" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1289" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="put,HttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#put%2CHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">put</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1291" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1291" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="putContent-procs-all">
- <div id="putContent,AsyncHttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#putContent%2CAsyncHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">putContent</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</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#string"><span class="Identifier">string</span></a><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>.}</pre></dt>
- <dd>
-
- Connects to the hostname specified by the URL andreturns the content of a PUT request.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1296" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1296" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="putContent,HttpClient,,string,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#putContent%2CHttpClient%2C%2Cstring%2CMultipartData"><span class="Identifier">putContent</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
- <span class="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</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/httpclient.nim#L1297" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1297" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="request-procs-all">
- <div id="request,AsyncHttpClient,,string,HttpHeaders,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#request%2CAsyncHttpClient%2C%2Cstring%2CHttpHeaders%2CMultipartData"><span class="Identifier">request</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#AsyncHttpClient"><span class="Identifier">AsyncHttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span>
- <span class="Identifier">httpMethod</span><span class="Other">:</span> <a href="httpcore.html#HttpMethod"><span class="Identifier">HttpMethod</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="Identifier">HttpGet</span><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><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="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</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="httpclient.html#AsyncResponse"><span class="Identifier">AsyncResponse</span></a><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>.}</pre></dt>
- <dd>
-
- <p>Connects to the hostname specified by the URL and performs a request using the custom method string specified by <tt class="docutils literal"><span class="pre"><span class="Identifier">httpMethod</span></span></tt>.</p>
- <p>Connection will be kept alive. Further requests on the same <tt class="docutils literal"><span class="pre"><span class="Identifier">client</span></span></tt> to the same hostname will not require a new connection to be made. The connection can be closed by using the <tt class="docutils literal"><span class="pre"><span class="Identifier">close</span></span></tt> procedure.</p>
- <p>This procedure will follow redirects up to a maximum number of redirects specified in <tt class="docutils literal"><span class="pre"><span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">maxRedirects</span></span></tt>.</p>
- <p>You need to make sure that the <tt class="docutils literal"><span class="pre"><span class="Identifier">url</span></span></tt> doesn't contain any newline characters. Failing to do so will raise <tt class="docutils literal"><span class="pre"><span class="Identifier">AssertionDefect</span></span></tt>.</p>
- <p><tt class="docutils literal"><span class="pre"><span class="Identifier">headers</span></span></tt> are HTTP headers that override the <tt class="docutils literal"><span class="pre"><span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">headers</span></span></tt> for this specific request only and will not be persisted.</p>
- <p><strong>Deprecated since v1.5</strong>: use HttpMethod enum instead; string parameter httpMethod is deprecated</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1131" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1131" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="request,HttpClient,,string,HttpHeaders,MultipartData">
- <dt><pre><span class="Keyword">proc</span> <a href="#request%2CHttpClient%2C%2Cstring%2CHttpHeaders%2CMultipartData"><span class="Identifier">request</span></a><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <a href="httpclient.html#HttpClient"><span class="Identifier">HttpClient</span></a><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <a href="uri.html#Uri"><span class="Identifier">Uri</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span>
- <span class="Identifier">httpMethod</span><span class="Other">:</span> <a href="httpcore.html#HttpMethod"><span class="Identifier">HttpMethod</span></a> <span class="Operator">|</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="Identifier">HttpGet</span><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">""</span><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="Identifier">multipart</span><span class="Other">:</span> <a href="httpclient.html#MultipartData"><span class="Identifier">MultipartData</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <a href="httpclient.html#Response"><span class="Identifier">Response</span></a></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/httpclient.nim#L1135" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/httpclient.nim#L1135" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- </div>
- </div>
- <div class="twelve-columns footer">
- <span class="nim-sprite"></span>
- <br>
- <small style="color: var(--hint);">Made with Nim. Generated: 2024-12-25 13:28:09 UTC</small>
- </div>
- </div>
- </div>
- <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
-
- </body>
- </html>
|