Skip to content

Instantly share code, notes, and snippets.

@FedericoCeratto
Created November 11, 2017 15:19
Show Gist options
  • Save FedericoCeratto/db002f193d0f8ba311aab883adf7e9d3 to your computer and use it in GitHub Desktop.
Save FedericoCeratto/db002f193d0f8ba311aab883adf7e9d3 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 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=="/>
<!-- 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'/>
<!-- CSS -->
<title>Module httpclient</title>
<style type="text/css" >
/*
Stylesheet for use with Docutils/rst2html.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Modified from Chad Skeeters' rst2html-style
https://bitbucket.org/cskeeters/rst2html-style/
Modified by Boyd Greenfield
*/
/* SCSS variables */
/* Text weights */
/* Body colors */
/* Text colors */
/* Link colors */
/* Syntax highlighting colors */
/* Pct changes */
/* Mixins */
/* Body/layout */
html {
font-size: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%; }
/* Where we want fancier font if available */
h1, h2, h3, h4, h5, h6, p.module-desc, table.docinfo + blockquote p, table.docinfo blockquote p, h1 + blockquote p {
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif !important; }
h1.title {
font-weight: 900; }
body {
font-family: "Helvetica Neue", "HelveticaNeue", "Lato", Helvetica, Arial, sans-serif;
font-weight: 400;
font-size: 15px;
line-height: 20px;
color: #333;
background-color: rgba(252, 248, 244, 0.75); }
/* Skeleton grid */
.container {
position: relative;
width: 100%;
max-width: 960px;
margin: 0 auto;
padding: 0 20px;
box-sizing: border-box; }
.column,
.columns {
width: 100%;
float: left;
box-sizing: border-box; }
/* For devices larger than 400px */
@media (min-width: 400px) {
.container {
width: 100%;
padding: 0; } }
/* For devices larger than 650px */
@media (min-width: 650px) {
.container {
width: 100%; }
.column,
.columns {
margin-left: 4%; }
.column:first-child,
.columns:first-child {
margin-left: 0; }
.one.column,
.one.columns {
width: 4.66666666667%; }
.two.columns {
width: 13.3333333333%; }
.three.columns {
width: 22%; }
.four.columns {
width: 30.6666666667%; }
.five.columns {
width: 39.3333333333%; }
.six.columns {
width: 48%; }
.seven.columns {
width: 56.6666666667%; }
.eight.columns {
width: 65.3333333333%; }
.nine.columns {
width: 74.0%; }
.ten.columns {
width: 82.6666666667%; }
.eleven.columns {
width: 91.3333333333%; }
.twelve.columns {
width: 100%;
margin-left: 0; }
.one-third.column {
width: 30.6666666667%; }
.two-thirds.column {
width: 65.3333333333%; } }
/* Customer Overrides */
.footer {
text-align: center;
color: #969696;
padding-top: 10%; }
p.module-desc {
font-size: 1.1em;
color: #666666; }
a.link-seesrc {
color: #aec7d2;
font-style: italic; }
a.link-seesrc:hover {
color: #6c9aae; }
#toc-list {
word-wrap: break-word; }
ul.simple-toc {
list-style: none; }
ul.simple-toc a.reference-toplevel {
font-weight: bold;
color: #0077b3; }
ul.simple-toc-section {
list-style-type: circle;
color: #6c9aae; }
ul.simple-toc-section a.reference {
color: #0077b3; }
cite {
font-style: italic !important; }
dt > pre {
border-color: rgba(0, 0, 0, 0.1);
background-color: rgba(255, 255, 255, 0.3);
margin: 15px 0px 5px; }
dd > pre {
border-color: rgba(0, 0, 0, 0.1);
background-color: whitesmoke;
margin-top: 8px; }
.item > dd {
margin-left: 10px;
margin-bottom: 30px; }
/* Nim line-numbered tables */
.line-nums-table {
width: 100%;
table-layout: fixed; }
table.line-nums-table {
border-radius: 4px;
border: 1px solid #cccccc;
background-color: whitesmoke;
border-collapse: separate;
margin-top: 15px;
margin-bottom: 25px; }
.line-nums-table tbody {
border: none; }
.line-nums-table td pre {
border: none;
background-color: transparent; }
.line-nums-table td.blob-line-nums {
width: 28px; }
.line-nums-table td.blob-line-nums pre {
color: #b0b0b0;
-webkit-filter: opacity(75%);
text-align: right;
border-color: transparent;
background-color: transparent;
padding-left: 0px;
margin-left: 0px;
padding-right: 0px;
margin-right: 0px; }
/* Docgen styles */
/* Links */
a {
color: #0077b3;
text-decoration: none; }
a:hover,
a:focus {
color: #00334d;
text-decoration: underline; }
a:visited {
color: #00334d; }
a:focus {
outline: thin dotted #2d2d2d;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px; }
a:hover,
a:active {
outline: 0; }
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline; }
sup {
top: -0.5em; }
sub {
bottom: -0.25em; }
img {
width: auto;
height: auto;
max-width: 100%;
vertical-align: middle;
border: 0;
-ms-interpolation-mode: bicubic; }
@media print {
* {
color: black !important;
text-shadow: none !important;
background: transparent !important;
box-shadow: none !important; }
a,
a:visited {
text-decoration: underline; }
a[href]:after {
content: " (" attr(href) ")"; }
abbr[title]:after {
content: " (" attr(title) ")"; }
.ir a:after,
a[href^="javascript:"]:after,
a[href^="#"]:after {
content: ""; }
pre,
blockquote {
border: 1px solid #999;
page-break-inside: avoid; }
thead {
display: table-header-group; }
tr,
img {
page-break-inside: avoid; }
img {
max-width: 100% !important; }
@page {
margin: 0.5cm; }
h1 {
page-break-before: always; }
h1.title {
page-break-before: avoid; }
p,
h2,
h3 {
orphans: 3;
widows: 3; }
h2,
h3 {
page-break-after: avoid; } }
.img-rounded {
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px; }
.img-polaroid {
padding: 4px;
background-color: rgba(252, 248, 244, 0.75);
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
p {
margin: 0 0 8px; }
small {
font-size: 85%; }
strong {
font-weight: 600; }
em {
font-style: italic; }
cite {
font-style: normal; }
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Helvetica Neue", "HelveticaNeue", "Lato", Helvetica, Arial, sans-serif;
font-weight: 600;
line-height: 20px;
color: inherit;
text-rendering: optimizelegibility; }
h1 {
font-size: 2em;
font-weight: 400;
padding-bottom: .15em;
border-bottom: 1px solid #aaaaaa;
margin-top: 1.0em;
line-height: 1.2em; }
h1.title {
padding-bottom: 1em;
border-bottom: 0px;
font-size: 2.75em; }
h2 {
font-size: 1.5em;
margin-top: 1.5em; }
h3 {
font-size: 1.3em;
font-style: italic;
margin-top: 0.75em; }
h4 {
font-size: 1.3em;
margin-top: 0.5em; }
h5 {
font-size: 1.2em;
margin-top: 0.25em; }
h6 {
font-size: 1.1em; }
ul,
ol {
padding: 0;
margin: 0 0 0px 15px; }
ul ul,
ul ol,
ol ol,
ol ul {
margin-bottom: 0; }
li {
line-height: 20px; }
dl {
margin-bottom: 20px; }
dt,
dd {
line-height: 20px; }
dt {
font-weight: bold; }
dd {
margin-left: 10px;
margin-bottom: 26px; }
hr {
margin: 20px 0;
border: 0;
border-top: 1px solid #eeeeee;
border-bottom: 1px solid #ffffff; }
abbr[title],
abbr[data-original-title] {
cursor: help;
border-bottom: 1px dotted #999999; }
abbr.initialism {
font-size: 90%;
text-transform: uppercase; }
blockquote {
padding: 0 0 0 15px;
margin: 0 0 20px;
border-left: 5px solid #EFEBE0; }
table.docinfo + blockquote, table.docinfo blockquote, h1 + blockquote {
border-left: 5px solid #c9c9c9;
}
table.docinfo + blockquote p, table.docinfo blockquote p, h1 + blockquote p {
margin-bottom: 0;
font-size: 15px;
font-weight: 200;
line-height: 1.5;
font-style: italic; }
q:before,
q:after,
blockquote:before,
blockquote:after {
content: ""; }
address {
display: block;
margin-bottom: 20px;
font-style: normal;
line-height: 20px; }
code,
pre {
font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace;
padding: 0 3px 2px;
font-weight: 500;
font-size: 12px;
color: #444444;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px; }
.pre {
font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace;
font-weight: 600;
/*color: #504da6;*/
}
code {
padding: 2px 4px;
color: #444444;
white-space: nowrap;
background-color: white;
border: 1px solid #777777; }
pre {
display: inline-block;
box-sizing: border-box;
min-width: calc(100% - 19.5px);
padding: 9.5px;
margin: 0.25em 10px 10px 10px;
font-size: 14px;
line-height: 20px;
white-space: pre !important;
overflow-y: hidden;
overflow-x: visible;
background-color: rgba(0, 0, 0, 0.01);
border: 1px solid #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px; }
pre.prettyprint {
margin-bottom: 20px; }
pre code {
padding: 0;
color: inherit;
white-space: pre;
overflow-x: visible;
background-color: transparent;
border: 0; }
.pre-scrollable {
max-height: 340px;
overflow-y: scroll; }
table {
max-width: 100%;
background-color: transparent;
border-collapse: collapse;
border-spacing: 0; }
table th, table td {
padding: 0px 8px 0px;
}
.table {
width: 100%;
margin-bottom: 20px; }
.table th,
.table td {
padding: 8px;
line-height: 20px;
text-align: left;
vertical-align: top;
border-top: 1px solid #444444; }
.table th {
font-weight: bold; }
.table thead th {
vertical-align: bottom; }
.table caption + thead tr:first-child th,
.table caption + thead tr:first-child td,
.table colgroup + thead tr:first-child th,
.table colgroup + thead tr:first-child td,
.table thead:first-child tr:first-child th,
.table thead:first-child tr:first-child td {
border-top: 0; }
.table tbody + tbody {
border-top: 2px solid #444444; }
.table .table {
background-color: rgba(252, 248, 244, 0.75); }
.table-condensed th,
.table-condensed td {
padding: 4px 5px; }
.table-bordered {
border: 1px solid #444444;
border-collapse: separate;
*border-collapse: collapse;
border-left: 0;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px; }
.table-bordered th,
.table-bordered td {
border-left: 1px solid #444444; }
.table-bordered caption + thead tr:first-child th,
.table-bordered caption + tbody tr:first-child th,
.table-bordered caption + tbody tr:first-child td,
.table-bordered colgroup + thead tr:first-child th,
.table-bordered colgroup + tbody tr:first-child th,
.table-bordered colgroup + tbody tr:first-child td,
.table-bordered thead:first-child tr:first-child th,
.table-bordered tbody:first-child tr:first-child th,
.table-bordered tbody:first-child tr:first-child td {
border-top: 0; }
.table-bordered thead:first-child tr:first-child > th:first-child,
.table-bordered tbody:first-child tr:first-child > td:first-child,
.table-bordered tbody:first-child tr:first-child > th:first-child {
-webkit-border-top-left-radius: 4px;
border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px; }
.table-bordered thead:first-child tr:first-child > th:last-child,
.table-bordered tbody:first-child tr:first-child > td:last-child,
.table-bordered tbody:first-child tr:first-child > th:last-child {
-webkit-border-top-right-radius: 4px;
border-top-right-radius: 4px;
-moz-border-radius-topright: 4px; }
.table-bordered thead:last-child tr:last-child > th:first-child,
.table-bordered tbody:last-child tr:last-child > td:first-child,
.table-bordered tbody:last-child tr:last-child > th:first-child,
.table-bordered tfoot:last-child tr:last-child > td:first-child,
.table-bordered tfoot:last-child tr:last-child > th:first-child {
-webkit-border-bottom-left-radius: 4px;
border-bottom-left-radius: 4px;
-moz-border-radius-bottomleft: 4px; }
.table-bordered thead:last-child tr:last-child > th:last-child,
.table-bordered tbody:last-child tr:last-child > td:last-child,
.table-bordered tbody:last-child tr:last-child > th:last-child,
.table-bordered tfoot:last-child tr:last-child > td:last-child,
.table-bordered tfoot:last-child tr:last-child > th:last-child {
-webkit-border-bottom-right-radius: 4px;
border-bottom-right-radius: 4px;
-moz-border-radius-bottomright: 4px; }
.table-bordered tfoot + tbody:last-child tr:last-child td:first-child {
-webkit-border-bottom-left-radius: 0;
border-bottom-left-radius: 0;
-moz-border-radius-bottomleft: 0; }
.table-bordered tfoot + tbody:last-child tr:last-child td:last-child {
-webkit-border-bottom-right-radius: 0;
border-bottom-right-radius: 0;
-moz-border-radius-bottomright: 0; }
.table-bordered caption + thead tr:first-child th:first-child,
.table-bordered caption + tbody tr:first-child td:first-child,
.table-bordered colgroup + thead tr:first-child th:first-child,
.table-bordered colgroup + tbody tr:first-child td:first-child {
-webkit-border-top-left-radius: 4px;
border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px; }
.table-bordered caption + thead tr:first-child th:last-child,
.table-bordered caption + tbody tr:first-child td:last-child,
.table-bordered colgroup + thead tr:first-child th:last-child,
.table-bordered colgroup + tbody tr:first-child td:last-child {
-webkit-border-top-right-radius: 4px;
border-top-right-radius: 4px;
-moz-border-radius-topright: 4px; }
table.docutils th {
background-color: #e8e8e8; }
table.docutils tr:hover {
background-color: whitesmoke; }
.table-striped tbody > tr:nth-child(odd) > td,
.table-striped tbody > tr:nth-child(odd) > th {
background-color: rgba(252, 248, 244, 0.75); }
.table-hover tbody tr:hover > td,
.table-hover tbody tr:hover > th {
background-color: rgba(241, 222, 204, 0.75); }
table td[class*="span"],
table th[class*="span"],
.row-fluid table td[class*="span"],
.row-fluid table th[class*="span"] {
display: table-cell;
float: none;
margin-left: 0; }
.hero-unit {
padding: 60px;
margin-bottom: 30px;
font-size: 18px;
font-weight: 200;
line-height: 30px;
color: inherit;
background-color: rgba(230, 197, 164, 0.75);
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px; }
.hero-unit h1 {
margin-bottom: 0;
font-size: 60px;
line-height: 1;
letter-spacing: -1px;
color: inherit; }
.hero-unit li {
line-height: 30px; }
/* rst2html default used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0; }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 !important; }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 !important; }
.last, .with-subtitle {
margin-bottom: 0 !important; }
.hidden {
display: none; }
a.toc-backref {
text-decoration: none;
color: #444444; }
blockquote.epigraph {
margin: 2em 5em; }
dl.docutils dd {
margin-bottom: 0.5em; }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden; }
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em; }
div.abstract p.topic-title {
font-weight: bold;
text-align: center; }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em;
border: medium outset;
padding: 1em; }
div.note, div.warning {
margin: 1.5em 0px;
border: none; }
div.note p.admonition-title,
div.warning p.admonition-title {
display: none; }
/* Clearfix
* http://css-tricks.com/snippets/css/clear-fix/
*/
div.note:after,
div.warning:after {
content: "";
display: table;
clear: both; }
div.note p:before,
div.warning p:before {
display: block;
float: left;
font-size: 4em;
line-height: 1em;
margin-right: 20px;
margin-left: 0em;
margin-top: -10px;
content: '\0270D';
/*handwriting*/ }
div.warning p:before {
content: '\026A0';
/*warning*/ }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold;
font-family: "Helvetica Neue", "HelveticaNeue", "Lato", Helvetica, Arial, sans-serif; }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: #b30000;
font-weight: bold;
font-family: "Helvetica Neue", "HelveticaNeue", "Lato", Helvetica, Arial, sans-serif; }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em;
text-align: center;
font-style: italic; }
div.dedication p.topic-title {
font-weight: bold;
font-style: normal; }
div.figure {
margin-left: 2em;
margin-right: 2em; }
div.footer, div.header {
clear: both;
font-size: smaller; }
div.line-block {
display: block;
margin-top: 1em;
margin-bottom: 1em; }
div.line-block div.line-block {
margin-top: 0;
margin-bottom: 0;
margin-left: 1.5em; }
div.sidebar {
margin: 0 0 0.5em 1em;
border: medium outset;
padding: 1em;
background-color: rgba(252, 248, 244, 0.75);
width: 40%;
float: right;
clear: right; }
div.sidebar p.rubric {
font-family: "Helvetica Neue", "HelveticaNeue", "Lato", Helvetica, Arial, sans-serif;
font-size: medium; }
div.system-messages {
margin: 5em; }
div.system-messages h1 {
color: #b30000; }
div.system-message {
border: medium outset;
padding: 1em; }
div.system-message p.system-message-title {
color: #b30000;
font-weight: bold; }
div.topic {
margin: 2em; }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em; }
h1.title {
text-align: center; }
h2.subtitle {
text-align: center; }
hr.docutils {
width: 75%; }
img.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em; }
img.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em; }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto; }
.align-left {
text-align: left; }
.align-center {
clear: both;
text-align: center; }
.align-right {
text-align: right; }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit; }
/* div.align-center * { */
/* text-align: left } */
ul.simple > li {
margin-bottom: 0.5em }
ol.simple, ul.simple {
margin-bottom: 1em; }
ol.arabic {
list-style: decimal; }
ol.loweralpha {
list-style: lower-alpha; }
ol.upperalpha {
list-style: upper-alpha; }
ol.lowerroman {
list-style: lower-roman; }
ol.upperroman {
list-style: upper-roman; }
p.attribution {
text-align: right;
margin-left: 50%; }
p.caption {
font-style: italic; }
p.credits {
font-style: italic;
font-size: smaller; }
p.label {
white-space: nowrap; }
p.rubric {
font-weight: bold;
font-size: larger;
color: maroon;
text-align: center; }
p.sidebar-title {
font-family: "Helvetica Neue", "HelveticaNeue", "Lato", Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: larger; }
p.sidebar-subtitle {
font-family: "Helvetica Neue", "HelveticaNeue", "Lato", Helvetica, Arial, sans-serif;
font-weight: bold; }
p.topic-title {
font-weight: bold; }
pre.address {
margin-bottom: 0;
margin-top: 0;
font: inherit; }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em;
margin-right: 2em; }
pre.code .ln {
color: grey; }
/* line numbers */
pre.code, code {
background-color: #eeeeee; }
pre.code .comment, code .comment {
color: #5c6576; }
pre.code .keyword, code .keyword {
color: #3B0D06;
font-weight: bold; }
pre.code .literal.string, code .literal.string {
color: #0c5404; }
pre.code .name.builtin, code .name.builtin {
color: #352b84; }
pre.code .deleted, code .deleted {
background-color: #DEB0A1; }
pre.code .inserted, code .inserted {
background-color: #A3D289; }
span.classifier {
font-family: "Helvetica Neue", "HelveticaNeue", "Lato", Helvetica, Arial, sans-serif;
font-style: oblique; }
span.classifier-delimiter {
font-family: "Helvetica Neue", "HelveticaNeue", "Lato", Helvetica, Arial, sans-serif;
font-weight: bold; }
span.interpreted {
font-family: "Helvetica Neue", "HelveticaNeue", "Lato", Helvetica, Arial, sans-serif; }
span.option {
white-space: nowrap; }
span.pre {
white-space: pre; }
span.problematic {
color: #b30000; }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80%; }
table.citation {
border-left: solid 1px #666666;
margin-left: 1px; }
table.docinfo {
margin: 0em;
margin-top: 2em;
margin-bottom: 2em;
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif !important;
color: #444444; }
table.docutils {
margin-top: 0.5em;
margin-bottom: 0.5em; }
table.footnote {
border-left: solid 1px #2d2d2d;
margin-left: 1px; }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em;
padding-right: 0.5em;
vertical-align: top; }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: 700;
text-align: left;
white-space: nowrap;
padding-left: 0; }
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100%; }
ul.auto-toc {
list-style-type: none; }
span.DecNumber {
color: #252dbe; }
span.BinNumber {
color: #252dbe; }
span.HexNumber {
color: #252dbe; }
span.OctNumber {
color: #252dbe; }
span.FloatNumber {
color: #252dbe; }
span.Identifier {
color: #3b3b3b; }
span.Keyword {
font-weight: 600;
color: #5e8f60; }
span.StringLit {
color: #a4255b; }
span.LongStringLit {
color: #a4255b; }
span.CharLit {
color: #a4255b; }
span.EscapeSequence {
color: black; }
span.Operator {
color: black; }
span.Punctuation {
color: black; }
span.Comment, span.LongComment {
font-style: italic;
font-weight: 400;
color: #484a86; }
span.RegularExpression {
color: darkviolet; }
span.TagStart {
color: darkviolet; }
span.TagEnd {
color: darkviolet; }
span.Key {
color: #252dbe; }
span.Value {
color: #252dbe; }
span.RawData {
color: #a4255b; }
span.Assembler {
color: #252dbe; }
span.Preprocessor {
color: #252dbe; }
span.Directive {
color: #252dbe; }
span.Command, span.Rule, span.Hyperlink, span.Label, span.Reference,
span.Other {
color: black; }
/* Pop type, const, proc, and iterator defs in nim def blocks */
dt pre > span.Identifier, dt pre > span.Operator {
color: #155da4;
font-weight: 700; }
dt pre > span.Identifier ~ span.Identifier, dt pre > span.Operator ~ span.Identifier {
color: inherit;
font-weight: inherit; }
dt pre > span.Operator ~ span.Identifier, dt pre > span.Operator ~ span.Operator {
color: inherit;
font-weight: inherit; }
/* Nim sprite for the footer (taken from main page favicon) */
.nim-sprite {
display: inline-block;
height: 12px;
width: 12px;
background-position: 0 0;
background-size: 12px 12px;
-webkit-filter: opacity(50%);
background-repeat: no-repeat;
background-image: url("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==");
margin-bottom: -5px; }
div.pragma {
display: none;
}
span.pragmabegin {
cursor: pointer;
}
span.pragmaend {
cursor: pointer;
}
div.search_results {
background-color: antiquewhite;
margin: 3em;
padding: 1em;
border: 1px solid #4d4d4d;
}
</style>
<script type="text/javascript" src="../dochack.js"></script>
<script type="text/javascript">
function togglepragma(d) {
if (d.style.display != 'inline')
d.style.display = 'inline';
else
d.style.display = 'none';
}
function main() {
var elements = document.getElementsByClassName("pragmabegin");
for (var i = 0; i < elements.length; ++i) {
var e = elements[i];
e.onclick = function(event) {
togglepragma(event.target.nextSibling);
};
}
var elements = document.getElementsByClassName("pragmaend");
for (var i = 0; i < elements.length; ++i) {
var e = elements[i];
e.onclick = function(event) {
togglepragma(event.target.previousSibling);
};
}
}
</script>
</head>
<body onload="main()">
<div class="document" id="documentId">
<div class="container">
<h1 class="title">Module httpclient</h1>
<div class="row">
<div class="three columns">
<div>
Search: <input type="text" id="searchInput"
onkeyup="search()" />
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</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="ssl-tls-support_toc" href="#ssl-tls-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 reference-toplevel" href="#6" id="56">Imports</a>
<ul class="simple simple-toc-section">
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#7" id="57">Types</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#Response"
title="Response* = ref object
version*: string
status*: string
headers*: HttpHeaders
body: string
bodyStream*: Stream"><wbr />Response<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#AsyncResponse"
title="AsyncResponse* = ref object
version*: string
status*: string
headers*: HttpHeaders
body: string
bodyStream*: FutureStream[string]"><wbr />Async<wbr />Response<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#Proxy"
title="Proxy* = ref object
url*: Uri
auth*: string"><wbr />Proxy<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#MultipartEntries"
title="MultipartEntries* = openarray[tuple[name, content: string]]"><wbr />Multipart<wbr />Entries<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#MultipartData"
title="MultipartData* = ref object
content: seq[string]"><wbr />Multipart<wbr />Data<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#ProtocolError"
title="ProtocolError* = object of IOError"><wbr />Protocol<wbr />Error<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#HttpRequestError"
title="HttpRequestError* = object of IOError"><wbr />Http<wbr />Request<wbr />Error<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#ProgressChangedProc"
title="ProgressChangedProc*[ReturnType] = proc (total, progress, speed: BiggestInt): ReturnType"><wbr />Progress<wbr />Changed<wbr />Proc<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#HttpClientBase"
title="HttpClientBase*[SocketType] = ref object
socket: SocketType
connected: bool
currentURL: Uri
headers*: HttpHeaders ## Headers to send in requests.
maxRedirects: int
userAgent: string
timeout: int ## Only used for blocking HttpClient for now.
proxy: Proxy ## ``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):
sslContext: net.SslContext
contentTotal: BiggestInt
contentProgress: BiggestInt
oneSecondProgress: BiggestInt
lastProgressReport: float
when SocketType is AsyncSocket:
bodyStream: FutureStream[string]
else:
bodyStream: Stream
getBody: bool ## When `false`, the body is never read in requestAux."><wbr />Http<wbr />Client<wbr />Base<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#HttpClient"
title="HttpClient* = HttpClientBase[Socket]"><wbr />Http<wbr />Client<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#AsyncHttpClient"
title="AsyncHttpClient* = HttpClientBase[AsyncSocket]"><wbr />Async<wbr />Http<wbr />Client<span class="attachedType" style="visibility:hidden"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#10" id="60">Consts</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#defUserAgent"
title="defUserAgent* = &quot;Nim httpclient&#x2F;&quot; &amp; NimVersion"><wbr />def<wbr />User<wbr />Agent<span class="attachedType" style="visibility:hidden"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#code,"
title="code*(response: Response | AsyncResponse): HttpCode"><wbr />code<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#body,Response"
title="body*(response: Response): string"><wbr />body<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#=,Response,string"
title="`body =`*(response: Response; value: string)">`<wbr />body<wbr />=`<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#body,AsyncResponse"
title="body*(response: AsyncResponse): Future[string]"><wbr />body<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#newProxy,string"
title="newProxy*(url: string; auth = &quot;&quot;): Proxy"><wbr />new<wbr />Proxy<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#newMultipartData,"
title="newMultipartData*(): MultipartData"><wbr />new<wbr />Multipart<wbr />Data<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#add,MultipartData,string,string,string,string"
title="add*(p: var MultipartData; name, content: string; filename: string = nil;
contentType: string = nil)"><wbr />add<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#add,MultipartData,MultipartEntries"
title="add*(p: var MultipartData; xs: MultipartEntries): MultipartData"><wbr />add<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#newMultipartData,MultipartEntries"
title="newMultipartData*(xs: MultipartEntries): MultipartData"><wbr />new<wbr />Multipart<wbr />Data<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#addFiles,MultipartData,openarray[tuple[string,string]]"
title="addFiles*(p: var MultipartData; xs: openarray[tuple[name, file: string]]): MultipartData"><wbr />add<wbr />Files<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#[]=,MultipartData,string,string"
title="`[]=`*(p: var MultipartData; name, content: string)">`<wbr />[]=`<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#[]=,MultipartData,string,tuple[string,string,string]"
title="`[]=`*(p: var MultipartData; name: string;
file: tuple[name, contentType, content: string])">`<wbr />[]=`<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#request,string,string,Proxy"
title="request*(url: string; httpMethod: string; extraHeaders = &quot;&quot;; body = &quot;&quot;;
sslContext = defaultSSLContext; timeout = -1; userAgent = defUserAgent;
proxy: Proxy = nil): Response"><wbr />request<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#request,string,Proxy"
title="request*(url: string; httpMethod = httpGET; extraHeaders = &quot;&quot;; body = &quot;&quot;;
sslContext = defaultSSLContext; timeout = -1; userAgent = defUserAgent;
proxy: Proxy = nil): Response"><wbr />request<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#get,string,SSLContext,Proxy"
title="get*(url: string; extraHeaders = &quot;&quot;; maxRedirects = 5;
sslContext: SSLContext = defaultSSLContext; timeout = -1;
userAgent = defUserAgent; proxy: Proxy = nil): Response"><wbr />get<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#getContent,string,SSLContext,Proxy"
title="getContent*(url: string; extraHeaders = &quot;&quot;; maxRedirects = 5;
sslContext: SSLContext = defaultSSLContext; timeout = -1;
userAgent = defUserAgent; proxy: Proxy = nil): string"><wbr />get<wbr />Content<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#post,string,SSLContext,Proxy,MultipartData"
title="post*(url: string; extraHeaders = &quot;&quot;; body = &quot;&quot;; maxRedirects = 5;
sslContext: SSLContext = defaultSSLContext; timeout = -1;
userAgent = defUserAgent; proxy: Proxy = nil; multipart: MultipartData = nil): Response"><wbr />post<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#postContent,string,SSLContext,Proxy,MultipartData"
title="postContent*(url: string; extraHeaders = &quot;&quot;; body = &quot;&quot;; maxRedirects = 5;
sslContext: SSLContext = defaultSSLContext; timeout = -1;
userAgent = defUserAgent; proxy: Proxy = nil;
multipart: MultipartData = nil): string"><wbr />post<wbr />Content<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#downloadFile,string,string,SSLContext,Proxy"
title="downloadFile*(url: string; outputFilename: string;
sslContext: SSLContext = defaultSSLContext; timeout = -1;
userAgent = defUserAgent; proxy: Proxy = nil)"><wbr />download<wbr />File<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#newHttpClient,Proxy"
title="newHttpClient*(userAgent = defUserAgent; maxRedirects = 5;
sslContext = defaultSslContext; proxy: Proxy = nil; timeout = -1): HttpClient"><wbr />new<wbr />Http<wbr />Client<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#newAsyncHttpClient,Proxy"
title="newAsyncHttpClient*(userAgent = defUserAgent; maxRedirects = 5;
sslContext = defaultSslContext; proxy: Proxy = nil): AsyncHttpClient"><wbr />new<wbr />Async<wbr />Http<wbr />Client<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#close,"
title="close*(client: HttpClient | AsyncHttpClient)"><wbr />close<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#request,,string,string,HttpHeaders"
title="request*(client: HttpClient | AsyncHttpClient; url: string; httpMethod: string;
body = &quot;&quot;; headers: HttpHeaders = nil): Future[Response | AsyncResponse]"><wbr />request<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#request,,string,HttpHeaders"
title="request*(client: HttpClient | AsyncHttpClient; url: string; httpMethod = HttpGET;
body = &quot;&quot;; headers: HttpHeaders = nil): Future[Response | AsyncResponse]"><wbr />request<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#get,,string"
title="get*(client: HttpClient | AsyncHttpClient; url: string): Future[
Response | AsyncResponse]"><wbr />get<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#getContent,,string"
title="getContent*(client: HttpClient | AsyncHttpClient; url: string): Future[string]"><wbr />get<wbr />Content<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#post,,string,MultipartData"
title="post*(client: HttpClient | AsyncHttpClient; url: string; body = &quot;&quot;;
multipart: MultipartData = nil): Future[Response | AsyncResponse]"><wbr />post<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#postContent,,string,MultipartData"
title="postContent*(client: HttpClient | AsyncHttpClient; url: string; body = &quot;&quot;;
multipart: MultipartData = nil): Future[string]"><wbr />post<wbr />Content<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#downloadFile,,string,string"
title="downloadFile*(client: HttpClient | AsyncHttpClient; url: string; filename: string): Future[
void]"><wbr />download<wbr />File<span class="attachedType" style="visibility:hidden"></span></a></li>
</ul>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<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.
<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">http://google.com</span></tt>:</p>
<pre class="listing"><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="Identifier">echo</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">getContent</span><span class="Punctuation">(</span><span class="StringLit">&quot;http://google.com&quot;</span><span class="Punctuation">)</span></pre><p>The same action can also be performed asynchronously, simply use the <tt class="docutils literal"><span class="pre">AsyncHttpClient</span></tt>:</p>
<pre class="listing"><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">echo</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">&quot;http://google.com&quot;</span><span class="Punctuation">)</span></pre><p>The functionality implemented by <tt class="docutils literal"><span class="pre">HttpClient</span></tt> and <tt class="docutils literal"><span class="pre">AsyncHttpClient</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 will need to run asynchronous examples in an async proc otherwise you will get an <tt class="docutils literal"><span class="pre">Undeclared identifier: 'await'</span></tt> error.</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">multipart/form-data</span></tt> as the <tt class="docutils literal"><span class="pre">Content-Type</span></tt> to send the HTML to be validated to the server.</p>
<pre class="listing"><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">&quot;output&quot;</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="StringLit">&quot;soap12&quot;</span>
<span class="Identifier">data</span><span class="Punctuation">[</span><span class="StringLit">&quot;uploaded_file&quot;</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Punctuation">(</span><span class="StringLit">&quot;test.html&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;text/html&quot;</span><span class="Punctuation">,</span>
<span class="StringLit">&quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;test&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&quot;</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">&quot;http://validator.w3.org/check&quot;</span><span class="Punctuation">,</span> <span class="Identifier">multipart</span><span class="Operator">=</span><span class="Identifier">data</span><span class="Punctuation">)</span></pre><p>You can also make post requests with custom headers. This example sets <tt class="docutils literal"><span class="pre">Content-Type</span></tt> to <tt class="docutils literal"><span class="pre">application/json</span></tt> and uses a json object for the body</p>
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">httpclient</span><span class="Punctuation">,</span> <span class="Identifier">json</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">&quot;Content-Type&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;application/json&quot;</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">&quot;data&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;some text&quot;</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">&quot;http://some.api&quot;</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></pre>
<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>
<pre class="listing"><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">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">&quot;Downloaded &quot;</span><span class="Punctuation">,</span> <span class="Identifier">progress</span><span class="Punctuation">,</span> <span class="StringLit">&quot; of &quot;</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">&quot;Current rate: &quot;</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">&quot;kb/s&quot;</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">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">&quot;http://speedtest-ams2.digitalocean.com/100mb.test&quot;</span><span class="Punctuation">)</span></pre><p>If you would like to remove the callback simply set it to <tt class="docutils literal"><span class="pre">nil</span></tt>.</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><strong>Warning:</strong> The <tt class="docutils literal"><span class="pre">total</span></tt> reported by httpclient may be 0 in some cases.</p>
<h1><a class="toc-backref" id="ssl-tls-support" href="#ssl-tls-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">https</span></tt> schema, for example: <tt class="docutils literal"><span class="pre">https://github.com/</span></tt>.</p>
<p>You will also have to compile with <tt class="docutils literal"><span class="pre">ssl</span></tt> defined like so: <tt class="docutils literal"><span class="pre">nim c -d:ssl ...</span></tt>.</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">TimeoutError</span></tt> exception will be raised.</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">newProxy</span></tt> constructor. Unfortunately, only basic authentication is supported at the moment.</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="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="strtabs.html">strtabs</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="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>
</dl></div>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<dt id="Response"><a name="Response"></a><pre><span class="Identifier">Response</span><span class="Operator">*</span> <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> <span class="Identifier">string</span>
<span class="Identifier">status</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
<span class="Identifier">headers</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">HttpHeaders</span>
<span class="Identifier">body</span><span class="Other">:</span> <span class="Identifier">string</span>
<span class="Identifier">bodyStream</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">Stream</span>
</pre></dt>
<dd>
</dd>
<dt id="AsyncResponse"><a name="AsyncResponse"></a><pre><span class="Identifier">AsyncResponse</span><span class="Operator">*</span> <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> <span class="Identifier">string</span>
<span class="Identifier">status</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
<span class="Identifier">headers</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">HttpHeaders</span>
<span class="Identifier">body</span><span class="Other">:</span> <span class="Identifier">string</span>
<span class="Identifier">bodyStream</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">FutureStream</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span>
</pre></dt>
<dd>
</dd>
<dt id="Proxy"><a name="Proxy"></a><pre><span class="Identifier">Proxy</span><span class="Operator">*</span> <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> <span class="Identifier">Uri</span>
<span class="Identifier">auth</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
</pre></dt>
<dd>
</dd>
<dt id="MultipartEntries"><a name="MultipartEntries"></a><pre><span class="Identifier">MultipartEntries</span><span class="Operator">*</span> <span class="Other">=</span> <span class="Identifier">openarray</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">content</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">]</span><span class="Other">]</span></pre></dt>
<dd>
</dd>
<dt id="MultipartData"><a name="MultipartData"></a><pre><span class="Identifier">MultipartData</span><span class="Operator">*</span> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span>
<span class="Identifier">content</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span>
</pre></dt>
<dd>
</dd>
<dt id="ProtocolError"><a name="ProtocolError"></a><pre><span class="Identifier">ProtocolError</span><span class="Operator">*</span> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">IOError</span></pre></dt>
<dd>
exception that is raised when server does not conform to the implemented protocol
</dd>
<dt id="HttpRequestError"><a name="HttpRequestError"></a><pre><span class="Identifier">HttpRequestError</span><span class="Operator">*</span> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">IOError</span></pre></dt>
<dd>
Thrown in the <tt class="docutils literal"><span class="pre">getContent</span></tt> proc and <tt class="docutils literal"><span class="pre">postContent</span></tt> proc, when the server returns an error
</dd>
<dt id="ProgressChangedProc"><a name="ProgressChangedProc"></a><pre><span class="Identifier">ProgressChangedProc</span><span class="Operator">*</span><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> <span class="Identifier">BiggestInt</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">ReturnType</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">closure</span><span class="Other">,</span> <span class="Identifier">gcsafe</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
</dd>
<dt id="HttpClientBase"><a name="HttpClientBase"></a><pre><span class="Identifier">HttpClientBase</span><span class="Operator">*</span><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="Identifier">socket</span><span class="Other">:</span> <span class="Identifier">SocketType</span>
<span class="Identifier">connected</span><span class="Other">:</span> <span class="Identifier">bool</span>
<span class="Identifier">currentURL</span><span class="Other">:</span> <span class="Identifier">Uri</span>
<span class="Identifier">headers</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">HttpHeaders</span> <span class="Comment">## Headers to send in requests.</span>
<span class="Identifier">maxRedirects</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">userAgent</span><span class="Other">:</span> <span class="Identifier">string</span>
<span class="Identifier">timeout</span><span class="Other">:</span> <span class="Identifier">int</span> <span class="Comment">## Only used for blocking HttpClient for now.</span>
<span class="Identifier">proxy</span><span class="Other">:</span> <span class="Identifier">Proxy</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="Identifier">sslContext</span><span class="Other">:</span> <span class="Identifier">net</span><span class="Other">.</span><span class="Identifier">SslContext</span>
<span class="Identifier">contentTotal</span><span class="Other">:</span> <span class="Identifier">BiggestInt</span>
<span class="Identifier">contentProgress</span><span class="Other">:</span> <span class="Identifier">BiggestInt</span>
<span class="Identifier">oneSecondProgress</span><span class="Other">:</span> <span class="Identifier">BiggestInt</span>
<span class="Identifier">lastProgressReport</span><span class="Other">:</span> <span class="Identifier">float</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="Identifier">bodyStream</span><span class="Other">:</span> <span class="Identifier">FutureStream</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span>
<span class="Keyword">else</span><span class="Other">:</span>
<span class="Identifier">bodyStream</span><span class="Other">:</span> <span class="Identifier">Stream</span>
<span class="Identifier">getBody</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Comment">## When `false`, the body is never read in requestAux.</span>
</pre></dt>
<dd>
Where we are currently connected.
</dd>
<dt id="HttpClient"><a name="HttpClient"></a><pre><span class="Identifier">HttpClient</span><span class="Operator">*</span> <span class="Other">=</span> <span class="Identifier">HttpClientBase</span><span class="Other">[</span><span class="Identifier">Socket</span><span class="Other">]</span></pre></dt>
<dd>
</dd>
<dt id="AsyncHttpClient"><a name="AsyncHttpClient"></a><pre><span class="Identifier">AsyncHttpClient</span><span class="Operator">*</span> <span class="Other">=</span> <span class="Identifier">HttpClientBase</span><span class="Other">[</span><span class="Identifier">AsyncSocket</span><span class="Other">]</span></pre></dt>
<dd>
</dd>
</dl></div>
<div class="section" id="10">
<h1><a class="toc-backref" href="#10">Consts</a></h1>
<dl class="item">
<dt id="defUserAgent"><a name="defUserAgent"></a><pre><span class="Identifier">defUserAgent</span><span class="Operator">*</span> <span class="Other">=</span> <span class="StringLit">&quot;Nim httpclient/&quot;</span> <span class="Operator">&amp;</span> <span class="Identifier">NimVersion</span></pre></dt>
<dd>
</dd>
</dl></div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<dt id="code"><a name="code,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">code</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <span class="Identifier">Response</span> <span class="Operator">|</span> <span class="Identifier">AsyncResponse</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">HttpCode</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OverflowError</span><span class="Other">]</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>Retrieves the specified response's <tt class="docutils literal"><span class="pre">HttpCode</span></tt>.</p>
<p>Raises a <tt class="docutils literal"><span class="pre">ValueError</span></tt> if the response's <tt class="docutils literal"><span class="pre">status</span></tt> does not have a corresponding <tt class="docutils literal"><span class="pre">HttpCode</span></tt>.</p>
</dd>
<dt id="body"><a name="body,Response"></a><pre><span class="Keyword">proc</span> <span class="Identifier">body</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <span class="Identifier">Response</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span></pre></dt>
<dd>
<p>Retrieves the specified response's body.</p>
<p>The response's body stream is read synchronously.</p>
</dd>
<dt id="="><a name="=,Response,string"></a><pre><span class="Keyword">proc</span> <span class="Other">`</span><span class="Identifier">body</span> <span class="Operator">=</span><span class="Other">`</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <span class="Identifier">Response</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">deprecated</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>Setter for backward compatibility.</p>
<p><strong>This is deprecated and should not be used</strong>.</p>
</dd>
<dt id="body"><a name="body,AsyncResponse"></a><pre><span class="Keyword">proc</span> <span class="Identifier">body</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <span class="Identifier">AsyncResponse</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">async</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
Reads the response's body and caches it. The read is performed only once.
</dd>
<dt id="newProxy"><a name="newProxy,string"></a><pre><span class="Keyword">proc</span> <span class="Identifier">newProxy</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">auth</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Proxy</span></pre></dt>
<dd>
Constructs a new <tt class="docutils literal"><span class="pre">TProxy</span></tt> object.
</dd>
<dt id="newMultipartData"><a name="newMultipartData,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">newMultipartData</span><span class="Operator">*</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">MultipartData</span></pre></dt>
<dd>
Constructs a new <tt class="docutils literal"><span class="pre">MultipartData</span></tt> object.
</dd>
<dt id="add"><a name="add,MultipartData,string,string,string,string"></a><pre><span class="Keyword">proc</span> <span class="Identifier">add</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">MultipartData</span><span class="Other">;</span> <span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">content</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">;</span>
<span class="Identifier">contentType</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span></pre></dt>
<dd>
Add a value to the multipart data. Raises a <cite>ValueError</cite> exception if <cite>name</cite>, <cite>filename</cite> or <cite>contentType</cite> contain newline characters.
</dd>
<dt id="add"><a name="add,MultipartData,MultipartEntries"></a><pre><span class="Keyword">proc</span> <span class="Identifier">add</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">MultipartData</span><span class="Other">;</span> <span class="Identifier">xs</span><span class="Other">:</span> <span class="Identifier">MultipartEntries</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">MultipartData</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">discardable</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
Add a list of multipart entries to the multipart data <cite>p</cite>. All values are added without a filename and without a content type.<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">&quot;action&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;login&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;format&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;json&quot;</span><span class="Punctuation">}</span><span class="Punctuation">)</span></pre>
</dd>
<dt id="newMultipartData"><a name="newMultipartData,MultipartEntries"></a><pre><span class="Keyword">proc</span> <span class="Identifier">newMultipartData</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">xs</span><span class="Other">:</span> <span class="Identifier">MultipartEntries</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">MultipartData</span></pre></dt>
<dd>
Create a new multipart data object and fill it with the entries <cite>xs</cite> directly.<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">&quot;action&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;login&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;format&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;json&quot;</span><span class="Punctuation">}</span><span class="Punctuation">)</span></pre>
</dd>
<dt id="addFiles"><a name="addFiles,MultipartData,openarray[tuple[string,string]]"></a><pre><span class="Keyword">proc</span> <span class="Identifier">addFiles</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">MultipartData</span><span class="Other">;</span> <span class="Identifier">xs</span><span class="Other">:</span> <span class="Identifier">openarray</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">file</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">]</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">MultipartData</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">discardable</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
Add files to a multipart data object. The file will be opened from your disk, read and sent with the automatically determined MIME type. Raises an <cite>IOError</cite> if the file cannot be opened or reading fails. To manually specify file content, filename and MIME type, use <cite>[]=</cite> instead.<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">&quot;uploaded_file&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;public/test.html&quot;</span><span class="Punctuation">}</span><span class="Punctuation">)</span></pre>
</dd>
<dt id="[]="><a name="[]=,MultipartData,string,string"></a><pre><span class="Keyword">proc</span> <span class="Other">`</span><span class="Operator">[]=</span><span class="Other">`</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">MultipartData</span><span class="Other">;</span> <span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">content</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span></pre></dt>
<dd>
Add a multipart entry to the multipart data <cite>p</cite>. The value is added without a filename and without a content type.<pre class="listing"><span class="Identifier">data</span><span class="Punctuation">[</span><span class="StringLit">&quot;username&quot;</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="StringLit">&quot;NimUser&quot;</span></pre>
</dd>
<dt id="[]="><a name="[]=,MultipartData,string,tuple[string,string,string]"></a><pre><span class="Keyword">proc</span> <span class="Other">`</span><span class="Operator">[]=</span><span class="Other">`</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">MultipartData</span><span class="Other">;</span> <span class="Identifier">name</span><span class="Other">:</span> <span class="Identifier">string</span><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> <span class="Identifier">string</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
<dd>
Add a file to the multipart data <cite>p</cite>, specifying filename, contentType and content manually.<pre class="listing"><span class="Identifier">data</span><span class="Punctuation">[</span><span class="StringLit">&quot;uploaded_file&quot;</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Punctuation">(</span><span class="StringLit">&quot;test.html&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;text/html&quot;</span><span class="Punctuation">,</span>
<span class="StringLit">&quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;test&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&quot;</span><span class="Punctuation">)</span></pre>
</dd>
<dt id="request"><a name="request,string,string,Proxy"></a><pre><span class="Keyword">proc</span> <span class="Identifier">request</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">httpMethod</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">extraHeaders</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">;</span>
<span class="Identifier">sslContext</span> <span class="Other">=</span> <span class="Identifier">defaultSSLContext</span><span class="Other">;</span> <span class="Identifier">timeout</span> <span class="Other">=</span> <span class="Operator">-</span><span class="DecNumber">1</span><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">proxy</span><span class="Other">:</span> <span class="Identifier">Proxy</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Response</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">deprecated</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>Requests <tt class="docutils literal"><span class="pre">url</span></tt> with the custom method string specified by the<br /><tt class="docutils literal"><span class="pre">httpMethod</span></tt> parameter.<br />Extra headers can be specified and must be separated by <tt class="docutils literal"><span class="pre">\c\L</span></tt><br />An optional timeout can be specified in milliseconds, if reading from the<br /></p><p>server takes longer than specified an ETimeout exception will be raised.</p>
<p><strong>Deprecated since version 0.15.0</strong>: use <tt class="docutils literal"><span class="pre">HttpClient.request</span></tt> instead.</p>
</dd>
<dt id="request"><a name="request,string,Proxy"></a><pre><span class="Keyword">proc</span> <span class="Identifier">request</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">httpMethod</span> <span class="Other">=</span> <span class="Identifier">httpGET</span><span class="Other">;</span> <span class="Identifier">extraHeaders</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">;</span>
<span class="Identifier">sslContext</span> <span class="Other">=</span> <span class="Identifier">defaultSSLContext</span><span class="Other">;</span> <span class="Identifier">timeout</span> <span class="Other">=</span> <span class="Operator">-</span><span class="DecNumber">1</span><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">proxy</span><span class="Other">:</span> <span class="Identifier">Proxy</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Response</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">deprecated</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>Requests <tt class="docutils literal"><span class="pre">url</span></tt> with the specified <tt class="docutils literal"><span class="pre">httpMethod</span></tt>.<br />Extra headers can be specified and must be separated by <tt class="docutils literal"><span class="pre">\c\L</span></tt><br />An optional timeout can be specified in milliseconds, if reading from the<br /></p><p>server takes longer than specified an ETimeout exception will be raised.</p>
<p><strong>Deprecated since version 0.15.0</strong>: use <tt class="docutils literal"><span class="pre">HttpClient.request</span></tt> instead.</p>
</dd>
<dt id="get"><a name="get,string,SSLContext,Proxy"></a><pre><span class="Keyword">proc</span> <span class="Identifier">get</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">extraHeaders</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</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">SSLContext</span> <span class="Other">=</span> <span class="Identifier">defaultSSLContext</span><span class="Other">;</span> <span class="Identifier">timeout</span> <span class="Other">=</span> <span class="Operator">-</span><span class="DecNumber">1</span><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">proxy</span><span class="Other">:</span> <span class="Identifier">Proxy</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Response</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">deprecated</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>GETs the <tt class="docutils literal"><span class="pre">url</span></tt> and returns a <tt class="docutils literal"><span class="pre">Response</span></tt> object<br />This proc also handles redirection<br />Extra headers can be specified and must be separated by <tt class="docutils literal"><span class="pre">\c\L</span></tt>.<br />An optional timeout can be specified in milliseconds, if reading from the<br /></p><p>server takes longer than specified an ETimeout exception will be raised.</p>
<p>## <strong>Deprecated since version 0.15.0</strong>: use <tt class="docutils literal"><span class="pre">HttpClient.get</span></tt> instead.</p>
</dd>
<dt id="getContent"><a name="getContent,string,SSLContext,Proxy"></a><pre><span class="Keyword">proc</span> <span class="Identifier">getContent</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">extraHeaders</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</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">SSLContext</span> <span class="Other">=</span> <span class="Identifier">defaultSSLContext</span><span class="Other">;</span> <span class="Identifier">timeout</span> <span class="Other">=</span> <span class="Operator">-</span><span class="DecNumber">1</span><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">proxy</span><span class="Other">:</span> <span class="Identifier">Proxy</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">deprecated</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>GETs the body and returns it as a string.<br />Raises exceptions for the status codes <tt class="docutils literal"><span class="pre">4xx</span></tt> and <tt class="docutils literal"><span class="pre">5xx</span></tt><br />Extra headers can be specified and must be separated by <tt class="docutils literal"><span class="pre">\c\L</span></tt>.<br />An optional timeout can be specified in milliseconds, if reading from the<br /></p><p>server takes longer than specified an ETimeout exception will be raised.</p>
<p><strong>Deprecated since version 0.15.0</strong>: use <tt class="docutils literal"><span class="pre">HttpClient.getContent</span></tt> instead.</p>
</dd>
<dt id="post"><a name="post,string,SSLContext,Proxy,MultipartData"></a><pre><span class="Keyword">proc</span> <span class="Identifier">post</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">extraHeaders</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</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">SSLContext</span> <span class="Other">=</span> <span class="Identifier">defaultSSLContext</span><span class="Other">;</span> <span class="Identifier">timeout</span> <span class="Other">=</span> <span class="Operator">-</span><span class="DecNumber">1</span><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">proxy</span><span class="Other">:</span> <span class="Identifier">Proxy</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">;</span> <span class="Identifier">multipart</span><span class="Other">:</span> <span class="Identifier">MultipartData</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Response</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">deprecated</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>POSTs <tt class="docutils literal"><span class="pre">body</span></tt> to the <tt class="docutils literal"><span class="pre">url</span></tt> and returns a <tt class="docutils literal"><span class="pre">Response</span></tt> object.<br />This proc adds the necessary Content-Length header.<br />This proc also handles redirection.<br />Extra headers can be specified and must be separated by <tt class="docutils literal"><span class="pre">\c\L</span></tt>.<br />An optional timeout can be specified in milliseconds, if reading from the<br /></p><p>server takes longer than specified an ETimeout exception will be raised. | The optional <tt class="docutils literal"><span class="pre">multipart</span></tt> parameter can be used to create <tt class="docutils literal"><span class="pre">multipart/form-data</span></tt> POSTs comfortably.</p>
<p><strong>Deprecated since version 0.15.0</strong>: use <tt class="docutils literal"><span class="pre">HttpClient.post</span></tt> instead.</p>
</dd>
<dt id="postContent"><a name="postContent,string,SSLContext,Proxy,MultipartData"></a><pre><span class="Keyword">proc</span> <span class="Identifier">postContent</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">extraHeaders</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</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">SSLContext</span> <span class="Other">=</span> <span class="Identifier">defaultSSLContext</span><span class="Other">;</span> <span class="Identifier">timeout</span> <span class="Other">=</span> <span class="Operator">-</span><span class="DecNumber">1</span><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">proxy</span><span class="Other">:</span> <span class="Identifier">Proxy</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">;</span>
<span class="Identifier">multipart</span><span class="Other">:</span> <span class="Identifier">MultipartData</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">deprecated</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>POSTs <tt class="docutils literal"><span class="pre">body</span></tt> to <tt class="docutils literal"><span class="pre">url</span></tt> and returns the response's body as a string<br />Raises exceptions for the status codes <tt class="docutils literal"><span class="pre">4xx</span></tt> and <tt class="docutils literal"><span class="pre">5xx</span></tt><br />Extra headers can be specified and must be separated by <tt class="docutils literal"><span class="pre">\c\L</span></tt>.<br />An optional timeout can be specified in milliseconds, if reading from the<br /></p><p>server takes longer than specified an ETimeout exception will be raised. | The optional <tt class="docutils literal"><span class="pre">multipart</span></tt> parameter can be used to create <tt class="docutils literal"><span class="pre">multipart/form-data</span></tt> POSTs comfortably.</p>
<p><strong>Deprecated since version 0.15.0</strong>: use <tt class="docutils literal"><span class="pre">HttpClient.postContent</span></tt> instead.</p>
</dd>
<dt id="downloadFile"><a name="downloadFile,string,string,SSLContext,Proxy"></a><pre><span class="Keyword">proc</span> <span class="Identifier">downloadFile</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">outputFilename</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span>
<span class="Identifier">sslContext</span><span class="Other">:</span> <span class="Identifier">SSLContext</span> <span class="Other">=</span> <span class="Identifier">defaultSSLContext</span><span class="Other">;</span> <span class="Identifier">timeout</span> <span class="Other">=</span> <span class="Operator">-</span><span class="DecNumber">1</span><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">proxy</span><span class="Other">:</span> <span class="Identifier">Proxy</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">deprecated</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>Downloads <tt class="docutils literal"><span class="pre">url</span></tt> and saves it to <tt class="docutils literal"><span class="pre">outputFilename</span></tt><br />An optional timeout can be specified in milliseconds, if reading from the<br /></p><p>server takes longer than specified an ETimeout exception will be raised.</p>
<p><strong>Deprecated since version 0.16.2</strong>: use <tt class="docutils literal"><span class="pre">HttpClient.downloadFile</span></tt> instead.</p>
</dd>
<dt id="newHttpClient"><a name="newHttpClient,Proxy"></a><pre><span class="Keyword">proc</span> <span class="Identifier">newHttpClient</span><span class="Operator">*</span><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">defaultSslContext</span><span class="Other">;</span> <span class="Identifier">proxy</span><span class="Other">:</span> <span class="Identifier">Proxy</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">;</span> <span class="Identifier">timeout</span> <span class="Other">=</span> <span class="Operator">-</span><span class="DecNumber">1</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">HttpClient</span></pre></dt>
<dd>
<p>Creates a new HttpClient instance.</p>
<p><tt class="docutils literal"><span class="pre">userAgent</span></tt> specifies the user agent that will be used when making requests.</p>
<p><tt class="docutils literal"><span class="pre">maxRedirects</span></tt> specifies the maximum amount of redirects to follow, default is 5.</p>
<p><tt class="docutils literal"><span class="pre">sslContext</span></tt> specifies the SSL context to use for HTTPS requests.</p>
<p><tt class="docutils literal"><span class="pre">proxy</span></tt> specifies an HTTP proxy to use for this HTTP client's connections.</p>
<p><tt class="docutils literal"><span class="pre">timeout</span></tt> specifies the number of milliseconds to allow before a <tt class="docutils literal"><span class="pre">TimeoutError</span></tt> is raised.</p>
</dd>
<dt id="newAsyncHttpClient"><a name="newAsyncHttpClient,Proxy"></a><pre><span class="Keyword">proc</span> <span class="Identifier">newAsyncHttpClient</span><span class="Operator">*</span><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">defaultSslContext</span><span class="Other">;</span> <span class="Identifier">proxy</span><span class="Other">:</span> <span class="Identifier">Proxy</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">AsyncHttpClient</span></pre></dt>
<dd>
<p>Creates a new AsyncHttpClient instance.</p>
<p><tt class="docutils literal"><span class="pre">userAgent</span></tt> specifies the user agent that will be used when making requests.</p>
<p><tt class="docutils literal"><span class="pre">maxRedirects</span></tt> specifies the maximum amount of redirects to follow, default is 5.</p>
<p><tt class="docutils literal"><span class="pre">sslContext</span></tt> specifies the SSL context to use for HTTPS requests.</p>
<p><tt class="docutils literal"><span class="pre">proxy</span></tt> specifies an HTTP proxy to use for this HTTP client's connections.</p>
</dd>
<dt id="close"><a name="close,"></a><pre><span class="Keyword">proc</span> <span class="Identifier">close</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <span class="Identifier">HttpClient</span> <span class="Operator">|</span> <span class="Identifier">AsyncHttpClient</span><span class="Other">)</span></pre></dt>
<dd>
Closes any connections held by the HTTP client.
</dd>
<dt id="request"><a name="request,,string,string,HttpHeaders"></a><pre><span class="Keyword">proc</span> <span class="Identifier">request</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <span class="Identifier">HttpClient</span> <span class="Operator">|</span> <span class="Identifier">AsyncHttpClient</span><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">httpMethod</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span>
<span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">;</span> <span class="Identifier">headers</span><span class="Other">:</span> <span class="Identifier">HttpHeaders</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">Response</span> <span class="Operator">|</span> <span class="Identifier">AsyncResponse</span><span class="Other">]</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">multisync</span></div><span class="Other pragmaend">.}</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">httpMethod</span></tt>.</p>
<p>Connection will kept alive. Further requests on the same <tt class="docutils literal"><span class="pre">client</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">close</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">client.maxRedirects</span></tt>.</p>
</dd>
<dt id="request"><a name="request,,string,HttpHeaders"></a><pre><span class="Keyword">proc</span> <span class="Identifier">request</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <span class="Identifier">HttpClient</span> <span class="Operator">|</span> <span class="Identifier">AsyncHttpClient</span><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">httpMethod</span> <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">&quot;&quot;</span><span class="Other">;</span> <span class="Identifier">headers</span><span class="Other">:</span> <span class="Identifier">HttpHeaders</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">Response</span> <span class="Operator">|</span> <span class="Identifier">AsyncResponse</span><span class="Other">]</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">multisync</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>Connects to the hostname specified by the URL and performs a request using the method specified.</p>
<p>Connection will be kept alive. Further requests on the same <tt class="docutils literal"><span class="pre">client</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">close</span></tt> procedure.</p>
<p>When a request is made to a different hostname, the current connection will be closed.</p>
</dd>
<dt id="get"><a name="get,,string"></a><pre><span class="Keyword">proc</span> <span class="Identifier">get</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <span class="Identifier">HttpClient</span> <span class="Operator">|</span> <span class="Identifier">AsyncHttpClient</span><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span>
<span class="Identifier">Response</span> <span class="Operator">|</span> <span class="Identifier">AsyncResponse</span><span class="Other">]</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">multisync</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>Connects to the hostname specified by the URL and performs a GET request.</p>
<p>This procedure will follow redirects up to a maximum number of redirects specified in <tt class="docutils literal"><span class="pre">client.maxRedirects</span></tt>.</p>
</dd>
<dt id="getContent"><a name="getContent,,string"></a><pre><span class="Keyword">proc</span> <span class="Identifier">getContent</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <span class="Identifier">HttpClient</span> <span class="Operator">|</span> <span class="Identifier">AsyncHttpClient</span><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other pragmabegin">{.</span><div class="pragma">
<span class="Identifier">multisync</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>Connects to the hostname specified by the URL and performs a GET request.</p>
<p>This procedure will follow redirects up to a maximum number of redirects specified in <tt class="docutils literal"><span class="pre">client.maxRedirects</span></tt>.</p>
<p>A <tt class="docutils literal"><span class="pre">HttpRequestError</span></tt> will be raised if the server responds with a client error (status code 4xx) or a server error (status code 5xx).</p>
</dd>
<dt id="post"><a name="post,,string,MultipartData"></a><pre><span class="Keyword">proc</span> <span class="Identifier">post</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <span class="Identifier">HttpClient</span> <span class="Operator">|</span> <span class="Identifier">AsyncHttpClient</span><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">;</span>
<span class="Identifier">multipart</span><span class="Other">:</span> <span class="Identifier">MultipartData</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">Response</span> <span class="Operator">|</span> <span class="Identifier">AsyncResponse</span><span class="Other">]</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">multisync</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>Connects to the hostname specified by the URL and performs a POST request.</p>
<p>This procedure will follow redirects up to a maximum number of redirects specified in <tt class="docutils literal"><span class="pre">client.maxRedirects</span></tt>.</p>
</dd>
<dt id="postContent"><a name="postContent,,string,MultipartData"></a><pre><span class="Keyword">proc</span> <span class="Identifier">postContent</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <span class="Identifier">HttpClient</span> <span class="Operator">|</span> <span class="Identifier">AsyncHttpClient</span><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">body</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">;</span>
<span class="Identifier">multipart</span><span class="Other">:</span> <span class="Identifier">MultipartData</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other pragmabegin">{.</span><div class="pragma"><span class="Identifier">multisync</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
<p>Connects to the hostname specified by the URL and performs a POST request.</p>
<p>This procedure will follow redirects up to a maximum number of redirects specified in <tt class="docutils literal"><span class="pre">client.maxRedirects</span></tt>.</p>
<p>A <tt class="docutils literal"><span class="pre">HttpRequestError</span></tt> will be raised if the server responds with a client error (status code 4xx) or a server error (status code 5xx).</p>
</dd>
<dt id="downloadFile"><a name="downloadFile,,string,string"></a><pre><span class="Keyword">proc</span> <span class="Identifier">downloadFile</span><span class="Operator">*</span><span class="Other">(</span><span class="Identifier">client</span><span class="Other">:</span> <span class="Identifier">HttpClient</span> <span class="Operator">|</span> <span class="Identifier">AsyncHttpClient</span><span class="Other">;</span> <span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</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 pragmabegin">{.</span><div class="pragma"><span class="Identifier">multisync</span></div><span class="Other pragmaend">.}</span></pre></dt>
<dd>
Downloads <tt class="docutils literal"><span class="pre">url</span></tt> and saves it to <tt class="docutils literal"><span class="pre">filename</span></tt>.
</dd>
</dl></div>
</div>
</div>
<div class="row">
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small>Made with Nim. Generated: 2017-11-11 15:17:42 UTC</small>
</div>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment