httpclient uses strtabs

This commit is contained in:
Andreas Rumpf 2010-02-07 20:30:05 +01:00
commit 7db3d97cf9
9 changed files with 6013 additions and 5717 deletions

View file

@ -1,5 +1,5 @@
# This is the config file for the documentation generator. # This is the config file for the documentation generator.
# (c) 2009 Andreas Rumpf # (c) 2010 Andreas Rumpf
# Feel free to edit the templates as you need. # Feel free to edit the templates as you need.
split.item.toc = "20" split.item.toc = "20"
@ -36,7 +36,6 @@ doc.item.toc = """
doc.toc = """ doc.toc = """
<div class="navigation" id="navigation"> <div class="navigation" id="navigation">
<p class="topic-title first">Navigation</p>
<ul class="simple"> <ul class="simple">
$content $content
</ul> </ul>
@ -92,15 +91,12 @@ span.Command, span.Rule, span.Hyperlink, span.Label, span.Reference,
span.Other {color: black} span.Other {color: black}
div.navigation { div.navigation {
-moz-border-radius: 5px 5px 5px 5px;
float: left; float: left;
width: 30%; width: 30%;
margin: 0; padding: 0; margin: 0; padding: 0;
border: 3px outset #7F7F7F; border: 3px outset #7F7F7F;
background-color: #7F7F7F; background-color: #7F7F7F;
-moz-border-radius-bottomleft:5px;
-moz-border-radius-bottomright:5px;
-moz-border-radius-topleft:5px;
-moz-border-radius-topright:5px;
} }
div.navigation ul { div.navigation ul {
@ -132,19 +128,25 @@ dl.item dd pre {
border: 0px; border: 0px;
} }
dl.item dt, dl.item dt pre { dl.item dt, dl.item dt pre {
margin: 20pt 0 0 0; margin: 20pt 0 0 5pt;
} }
pre, span.tok { pre, span.tok {
background-color: #F9F9F9; background-color: #F9F9F9;
border:1px dotted #2F6FAB; border-color: #C4C4C4;
border-style: solid;
border-width: 1px 1px 1px 2px;
color: black; color: black;
line-spacing: 110%;
padding: 5px;
} }
span.red { span.red {
color: #A80000; color: #A80000;
} }
hr {background-color:#9D9D9D; border:0 none; color:#9D9D9D; height:1px; width:100%;}
/* /*
:Author: David Goodger :Author: David Goodger
:Contact: goodger@python.org :Contact: goodger@python.org
@ -232,7 +234,15 @@ p.label { white-space: nowrap }
p.rubric { font-weight:bold;font-size:larger;color:maroon;text-align:center} p.rubric { font-weight:bold;font-size:larger;color:maroon;text-align:center}
p.sidebar-title {font-family: sans-serif ;font-weight: bold ;font-size: larger } p.sidebar-title {font-family: sans-serif ;font-weight: bold ;font-size: larger }
p.sidebar-subtitle {font-family: sans-serif ; font-weight: bold } p.sidebar-subtitle {font-family: sans-serif ; font-weight: bold }
p.topic-title { font-weight: bold } p.topic-title {
font-weight: bold;
background-color: #6D6D6D;
border-bottom: 1px solid #000000;
border-top: 1px solid black;
color: white;
text-align: center;
margin: 0;
}
pre.address { margin-bottom: 0;margin-top:0;font-family:serif;font-size:100% } pre.address { margin-bottom: 0;margin-top:0;font-family:serif;font-size:100% }
pre.literal-block, pre.doctest-block {margin-left: 2em ;margin-right: 2em } pre.literal-block, pre.doctest-block {margin-left: 2em ;margin-right: 2em }
span.classifier {font-family: sans-serif;font-style: oblique } span.classifier {font-family: sans-serif;font-style: oblique }
@ -247,15 +257,28 @@ span.section-subtitle {
table.citation { border-left: solid 1px gray; margin-left: 1px } table.citation { border-left: solid 1px gray; margin-left: 1px }
table.docinfo {margin: 2em 4em } table.docinfo {margin: 2em 4em }
table.docutils {margin-top: 0.5em;margin-bottom: 0.5em } table.docutils {margin-top: 0.5em;margin-bottom: 0.5em; border: 0 solid #9d9d9d; border-collapse: collapse; }
table.footnote {border-left: solid 1px black;margin-left: 1px } table.footnote {border-left: solid 1px black;margin-left: 1px }
table.docutils td, table.docutils th, table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {padding-left: 0.5em;padding-right: 0.5em; table.docinfo td, table.docinfo th {padding-left: 0.5em;padding-right: 0.5em;
vertical-align: top} vertical-align: top; border-bottom:1px solid #9D9D9D; color: #4d4d4d}
table.docutils td:hover, table.docinfo td:hover {color: #000000}
table.docutils th.field-name, table.docinfo th.docinfo-name { table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold;text-align: left;white-space: nowrap;padding-left: 0 } font-weight: bold;text-align: left;white-space: nowrap;padding-left: 0 }
table.docutils th, table.docinfo th
{
color: black;
font-weight:normal;
background-color: #E3E3E3;
border-top: 1px solid #1d1d1d;
border-bottom: 1px solid #1d1d1d;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {font-size: 100% } h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {font-size: 100% }
ul.auto-toc { list-style-type: none } ul.auto-toc { list-style-type: none }
@ -275,4 +298,3 @@ $content
</body> </body>
</html> </html>
""" """

View file

@ -117,14 +117,14 @@ Internet Protocols and Support
* `sockets <sockets.html>` * `sockets <sockets.html>`
This module implements a simple portable type-safe sockets layer. This module implements a simple portable type-safe sockets layer.
* `browsers <browsers.html>` * `browsers <browsers.html>`_
This module implements procs for opening URLs with the user's default This module implements procs for opening URLs with the user's default
browser. browser.
* `httpserver <httpserver.html>` * `httpserver <httpserver.html>`_
This module implements a simple HTTP server. This module implements a simple HTTP server.
* `httpclient <httpclient.html>` * `httpclient <httpclient.html>`_
This module implements a simple HTTP client. This module implements a simple HTTP client.

View file

@ -26,11 +26,13 @@ Index
* `times.html#110 <times.html#110>`_ * `times.html#110 <times.html#110>`_
* `pegs.html#133 <pegs.html#133>`_ * `pegs.html#133 <pegs.html#133>`_
* `macros.html#115 <macros.html#115>`_ * `macros.html#115 <macros.html#115>`_
* `ropes.html#119 <ropes.html#119>`_
`%`:idx: `%`:idx:
* `strutils.html#109 <strutils.html#109>`_ * `strutils.html#109 <strutils.html#109>`_
* `strutils.html#110 <strutils.html#110>`_ * `strutils.html#110 <strutils.html#110>`_
* `strtabs.html#112 <strtabs.html#112>`_ * `strtabs.html#112 <strtabs.html#112>`_
* `ropes.html#120 <ropes.html#120>`_
`%%`:idx: `%%`:idx:
* `system.html#298 <system.html#298>`_ * `system.html#298 <system.html#298>`_
@ -48,6 +50,10 @@ Index
* `system.html#472 <system.html#472>`_ * `system.html#472 <system.html#472>`_
* `system.html#473 <system.html#473>`_ * `system.html#473 <system.html#473>`_
* `pegs.html#114 <pegs.html#114>`_ * `pegs.html#114 <pegs.html#114>`_
* `ropes.html#109 <ropes.html#109>`_
* `ropes.html#110 <ropes.html#110>`_
* `ropes.html#111 <ropes.html#111>`_
* `ropes.html#112 <ropes.html#112>`_
`*`:idx: `*`:idx:
* `system.html#218 <system.html#218>`_ * `system.html#218 <system.html#218>`_
@ -152,6 +158,9 @@ Index
* `system.html#352 <system.html#352>`_ * `system.html#352 <system.html#352>`_
* `times.html#114 <times.html#114>`_ * `times.html#114 <times.html#114>`_
`<%`:idx:
`unicode.html#104 <unicode.html#104>`_
`<%`:idx: `<%`:idx:
* `system.html#308 <system.html#308>`_ * `system.html#308 <system.html#308>`_
* `system.html#309 <system.html#309>`_ * `system.html#309 <system.html#309>`_
@ -159,8 +168,8 @@ Index
* `system.html#311 <system.html#311>`_ * `system.html#311 <system.html#311>`_
* `system.html#312 <system.html#312>`_ * `system.html#312 <system.html#312>`_
`<%`:idx: `<=`:idx:
`unicode.html#104 <unicode.html#104>`_ `times.html#115 <times.html#115>`_
`<=`:idx: `<=`:idx:
* `system.html#263 <system.html#263>`_ * `system.html#263 <system.html#263>`_
@ -177,8 +186,8 @@ Index
* `system.html#343 <system.html#343>`_ * `system.html#343 <system.html#343>`_
* `system.html#344 <system.html#344>`_ * `system.html#344 <system.html#344>`_
`<=`:idx: `<=%`:idx:
`times.html#115 <times.html#115>`_ `unicode.html#103 <unicode.html#103>`_
`<=%`:idx: `<=%`:idx:
* `system.html#303 <system.html#303>`_ * `system.html#303 <system.html#303>`_
@ -187,9 +196,6 @@ Index
* `system.html#306 <system.html#306>`_ * `system.html#306 <system.html#306>`_
* `system.html#307 <system.html#307>`_ * `system.html#307 <system.html#307>`_
`<=%`:idx:
`unicode.html#103 <unicode.html#103>`_
`==`:idx: `==`:idx:
* `md5.html#107 <md5.html#107>`_ * `md5.html#107 <md5.html#107>`_
* `system.html#258 <system.html#258>`_ * `system.html#258 <system.html#258>`_
@ -238,6 +244,9 @@ Index
* `system.html#363 <system.html#363>`_ * `system.html#363 <system.html#363>`_
* `pegs.html#112 <pegs.html#112>`_ * `pegs.html#112 <pegs.html#112>`_
`[]`:idx:
`ropes.html#115 <ropes.html#115>`_
`[]`:idx: `[]`:idx:
`macros.html#112 <macros.html#112>`_ `macros.html#112 <macros.html#112>`_
@ -245,10 +254,10 @@ Index
`strtabs.html#107 <strtabs.html#107>`_ `strtabs.html#107 <strtabs.html#107>`_
`[]=`:idx: `[]=`:idx:
`strtabs.html#106 <strtabs.html#106>`_ `macros.html#113 <macros.html#113>`_
`[]=`:idx: `[]=`:idx:
`macros.html#113 <macros.html#113>`_ `strtabs.html#106 <strtabs.html#106>`_
`[ESC]`:idx: `[ESC]`:idx:
`manual.html#134 <manual.html#134>`_ `manual.html#134 <manual.html#134>`_
@ -283,9 +292,12 @@ Index
* `parsesql.html#108 <parsesql.html#108>`_ * `parsesql.html#108 <parsesql.html#108>`_
* `macros.html#119 <macros.html#119>`_ * `macros.html#119 <macros.html#119>`_
* `macros.html#120 <macros.html#120>`_ * `macros.html#120 <macros.html#120>`_
* `ropes.html#113 <ropes.html#113>`_
* `ropes.html#114 <ropes.html#114>`_
`addf`:idx: `addf`:idx:
`strutils.html#111 <strutils.html#111>`_ * `strutils.html#111 <strutils.html#111>`_
* `ropes.html#121 <ropes.html#121>`_
`addFile`:idx: `addFile`:idx:
* `zipfiles.html#105 <zipfiles.html#105>`_ * `zipfiles.html#105 <zipfiles.html#105>`_
@ -634,15 +646,18 @@ Index
`clonglong`:idx: `clonglong`:idx:
`system.html#388 <system.html#388>`_ `system.html#388 <system.html#388>`_
`Close`:idx:
`system.html#510 <system.html#510>`_
`close`:idx: `close`:idx:
* `lexbase.html#105 <lexbase.html#105>`_ * `lexbase.html#105 <lexbase.html#105>`_
* `parsecfg.html#105 <parsecfg.html#105>`_ * `parsecfg.html#105 <parsecfg.html#105>`_
* `parsexml.html#108 <parsexml.html#108>`_ * `parsexml.html#108 <parsexml.html#108>`_
* `parsecsv.html#109 <parsecsv.html#109>`_ * `parsecsv.html#109 <parsecsv.html#109>`_
* `zipfiles.html#103 <zipfiles.html#103>`_ * `zipfiles.html#103 <zipfiles.html#103>`_
* `httpserver.html#106 <httpserver.html#106>`_
`Close`:idx:
* `system.html#510 <system.html#510>`_
* `db_postgres.html#117 <db_postgres.html#117>`_
* `db_mysql.html#117 <db_mysql.html#117>`_
`CloseFile`:idx: `CloseFile`:idx:
`system.html#509 <system.html#509>`_ `system.html#509 <system.html#509>`_
@ -698,12 +713,12 @@ Index
`CompileDate`:idx: `CompileDate`:idx:
`system.html#399 <system.html#399>`_ `system.html#399 <system.html#399>`_
`compileTime`:idx:
`manual.html#236 <manual.html#236>`_
`CompileTime`:idx: `CompileTime`:idx:
`system.html#400 <system.html#400>`_ `system.html#400 <system.html#400>`_
`compileTime`:idx:
`manual.html#236 <manual.html#236>`_
`complex statements`:idx: `complex statements`:idx:
`manual.html#184 <manual.html#184>`_ `manual.html#184 <manual.html#184>`_
@ -1164,9 +1179,16 @@ Index
`dangling else problem`:idx: `dangling else problem`:idx:
`manual.html#185 <manual.html#185>`_ `manual.html#185 <manual.html#185>`_
`dbError`:idx:
* `db_postgres.html#107 <db_postgres.html#107>`_
* `db_mysql.html#106 <db_mysql.html#106>`_
`dbgLineHook`:idx: `dbgLineHook`:idx:
`system.html#441 <system.html#441>`_ `system.html#441 <system.html#441>`_
`dbQueryOpt`:idx:
`db_mysql.html#107 <db_mysql.html#107>`_
`dd`:idx: `dd`:idx:
`xmlgen.html#123 <xmlgen.html#123>`_ `xmlgen.html#123 <xmlgen.html#123>`_
@ -1208,15 +1230,18 @@ Index
`dfn`:idx: `dfn`:idx:
`xmlgen.html#125 <xmlgen.html#125>`_ `xmlgen.html#125 <xmlgen.html#125>`_
`digits`:idx:
`pegs.html#126 <pegs.html#126>`_
`Digits`:idx: `Digits`:idx:
`strutils.html#104 <strutils.html#104>`_ `strutils.html#104 <strutils.html#104>`_
`digits`:idx:
`pegs.html#126 <pegs.html#126>`_
`DirSep`:idx: `DirSep`:idx:
`os.html#103 <os.html#103>`_ `os.html#103 <os.html#103>`_
`disableCache`:idx:
`ropes.html#107 <ropes.html#107>`_
`discard`:idx: `discard`:idx:
`manual.html#186 <manual.html#186>`_ `manual.html#186 <manual.html#186>`_
@ -1234,6 +1259,9 @@ Index
`domain specific languages`:idx: `domain specific languages`:idx:
`manual.html#222 <manual.html#222>`_ `manual.html#222 <manual.html#222>`_
`downloadFile`:idx:
`httpclient.html#111 <httpclient.html#111>`_
`dt`:idx: `dt`:idx:
`xmlgen.html#128 <xmlgen.html#128>`_ `xmlgen.html#128 <xmlgen.html#128>`_
@ -1276,6 +1304,10 @@ Index
`EControlC`:idx: `EControlC`:idx:
`system.html#151 <system.html#151>`_ `system.html#151 <system.html#151>`_
`EDb`:idx:
* `db_postgres.html#104 <db_postgres.html#104>`_
* `db_mysql.html#104 <db_mysql.html#104>`_
`editDistance`:idx: `editDistance`:idx:
`strutils.html#165 <strutils.html#165>`_ `strutils.html#165 <strutils.html#165>`_
@ -1305,6 +1337,9 @@ Index
* `manual.html#148 <manual.html#148>`_ * `manual.html#148 <manual.html#148>`_
* `system.html#165 <system.html#165>`_ * `system.html#165 <system.html#165>`_
`EHttpRequestErr`:idx:
`httpclient.html#104 <httpclient.html#104>`_
`EInvalidCsv`:idx: `EInvalidCsv`:idx:
`parsecsv.html#105 <parsecsv.html#105>`_ `parsecsv.html#105 <parsecsv.html#105>`_
@ -1326,6 +1361,9 @@ Index
`EInvalidPeg`:idx: `EInvalidPeg`:idx:
`pegs.html#150 <pegs.html#150>`_ `pegs.html#150 <pegs.html#150>`_
`EInvalidProtocol`:idx:
`httpclient.html#103 <httpclient.html#103>`_
`EInvalidRegEx`:idx: `EInvalidRegEx`:idx:
`regexprs.html#104 <regexprs.html#104>`_ `regexprs.html#104 <regexprs.html#104>`_
@ -1347,6 +1385,9 @@ Index
`Embedded Nimrod Debugger`:idx: `Embedded Nimrod Debugger`:idx:
`endb.html#101 <endb.html#101>`_ `endb.html#101 <endb.html#101>`_
`enableCache`:idx:
`ropes.html#108 <ropes.html#108>`_
`ENDB`:idx: `ENDB`:idx:
`endb.html#102 <endb.html#102>`_ `endb.html#102 <endb.html#102>`_
@ -1368,12 +1409,12 @@ Index
`enum_cursor_type`:idx: `enum_cursor_type`:idx:
`mysql.html#237 <mysql.html#237>`_ `mysql.html#237 <mysql.html#237>`_
`Enumeration`:idx:
`manual.html#155 <manual.html#155>`_
`enumeration`:idx: `enumeration`:idx:
`tut1.html#113 <tut1.html#113>`_ `tut1.html#113 <tut1.html#113>`_
`Enumeration`:idx:
`manual.html#155 <manual.html#155>`_
`enum_field_types`:idx: `enum_field_types`:idx:
`mysql.html#202 <mysql.html#202>`_ `mysql.html#202 <mysql.html#202>`_
@ -1411,6 +1452,10 @@ Index
`equalMem`:idx: `equalMem`:idx:
`system.html#418 <system.html#418>`_ `system.html#418 <system.html#418>`_
`equalsFile`:idx:
* `ropes.html#122 <ropes.html#122>`_
* `ropes.html#123 <ropes.html#123>`_
`EraseLine`:idx: `EraseLine`:idx:
`terminal.html#108 <terminal.html#108>`_ `terminal.html#108 <terminal.html#108>`_
@ -1552,6 +1597,10 @@ Index
`fastcall`:idx: `fastcall`:idx:
`manual.html#175 <manual.html#175>`_ `manual.html#175 <manual.html#175>`_
`FastRows`:idx:
* `db_postgres.html#110 <db_postgres.html#110>`_
* `db_mysql.html#110 <db_mysql.html#110>`_
`fastRuneAt`:idx: `fastRuneAt`:idx:
`unicode.html#108 <unicode.html#108>`_ `unicode.html#108 <unicode.html#108>`_
@ -1767,6 +1816,13 @@ Index
* `manual.html#218 <manual.html#218>`_ * `manual.html#218 <manual.html#218>`_
* `tut2.html#109 <tut2.html#109>`_ * `tut2.html#109 <tut2.html#109>`_
`get`:idx:
`httpclient.html#107 <httpclient.html#107>`_
`GetAllRows`:idx:
* `db_postgres.html#111 <db_postgres.html#111>`_
* `db_mysql.html#111 <db_mysql.html#111>`_
`getApplicationDir`:idx: `getApplicationDir`:idx:
`os.html#169 <os.html#169>`_ `os.html#169 <os.html#169>`_
@ -1786,6 +1842,9 @@ Index
`getConfigDir`:idx: `getConfigDir`:idx:
`os.html#167 <os.html#167>`_ `os.html#167 <os.html#167>`_
`getContent`:idx:
`httpclient.html#108 <httpclient.html#108>`_
`getContentLength`:idx: `getContentLength`:idx:
`cgi.html#111 <cgi.html#111>`_ `cgi.html#111 <cgi.html#111>`_
@ -1838,6 +1897,9 @@ Index
`getGMTime`:idx: `getGMTime`:idx:
`times.html#107 <times.html#107>`_ `times.html#107 <times.html#107>`_
`getHeaderValue`:idx:
`httpclient.html#105 <httpclient.html#105>`_
`getHomeDir`:idx: `getHomeDir`:idx:
`os.html#166 <os.html#166>`_ `os.html#166 <os.html#166>`_
@ -1974,6 +2036,10 @@ Index
`get_tty_password`:idx: `get_tty_password`:idx:
`mysql.html#282 <mysql.html#282>`_ `mysql.html#282 <mysql.html#282>`_
`GetValue`:idx:
* `db_postgres.html#113 <db_postgres.html#113>`_
* `db_mysql.html#113 <db_mysql.html#113>`_
`gptr`:idx: `gptr`:idx:
`mysql.html#105 <mysql.html#105>`_ `mysql.html#105 <mysql.html#105>`_
@ -2052,13 +2118,13 @@ Index
`hr`:idx: `hr`:idx:
`xmlgen.html#140 <xmlgen.html#140>`_ `xmlgen.html#140 <xmlgen.html#140>`_
`html`:idx:
`xmlgen.html#139 <xmlgen.html#139>`_
`HTML`:idx: `HTML`:idx:
* `parsexml.html#102 <parsexml.html#102>`_ * `parsexml.html#102 <parsexml.html#102>`_
* `xmlgen.html#102 <xmlgen.html#102>`_ * `xmlgen.html#102 <xmlgen.html#102>`_
`html`:idx:
`xmlgen.html#139 <xmlgen.html#139>`_
`HTTPPOST_BUFFER`:idx: `HTTPPOST_BUFFER`:idx:
`libcurl.html#266 <libcurl.html#266>`_ `libcurl.html#266 <libcurl.html#266>`_
@ -2090,12 +2156,12 @@ Index
`ident=`:idx: `ident=`:idx:
`macros.html#132 <macros.html#132>`_ `macros.html#132 <macros.html#132>`_
`identChars`:idx:
`pegs.html#128 <pegs.html#128>`_
`IdentChars`:idx: `IdentChars`:idx:
`strutils.html#105 <strutils.html#105>`_ `strutils.html#105 <strutils.html#105>`_
`identChars`:idx:
`pegs.html#128 <pegs.html#128>`_
`identifier`:idx: `identifier`:idx:
`manual.html#105 <manual.html#105>`_ `manual.html#105 <manual.html#105>`_
@ -2173,6 +2239,10 @@ Index
`insert`:idx: `insert`:idx:
`system.html#378 <system.html#378>`_ `system.html#378 <system.html#378>`_
`InsertID`:idx:
* `db_postgres.html#115 <db_postgres.html#115>`_
* `db_mysql.html#115 <db_mysql.html#115>`_
`int`:idx: `int`:idx:
`system.html#101 <system.html#101>`_ `system.html#101 <system.html#101>`_
@ -2260,6 +2330,7 @@ Index
* `system.html#462 <system.html#462>`_ * `system.html#462 <system.html#462>`_
* `system.html#463 <system.html#463>`_ * `system.html#463 <system.html#463>`_
* `system.html#464 <system.html#464>`_ * `system.html#464 <system.html#464>`_
* `ropes.html#117 <ropes.html#117>`_
`iterator`:idx: `iterator`:idx:
`manual.html#215 <manual.html#215>`_ `manual.html#215 <manual.html#215>`_
@ -2291,6 +2362,9 @@ Index
`label`:idx: `label`:idx:
`xmlgen.html#146 <xmlgen.html#146>`_ `xmlgen.html#146 <xmlgen.html#146>`_
`leaves`:idx:
`ropes.html#116 <ropes.html#116>`_
`legend`:idx: `legend`:idx:
`xmlgen.html#147 <xmlgen.html#147>`_ `xmlgen.html#147 <xmlgen.html#147>`_
@ -2303,6 +2377,7 @@ Index
* `strtabs.html#109 <strtabs.html#109>`_ * `strtabs.html#109 <strtabs.html#109>`_
* `parsesql.html#107 <parsesql.html#107>`_ * `parsesql.html#107 <parsesql.html#107>`_
* `macros.html#118 <macros.html#118>`_ * `macros.html#118 <macros.html#118>`_
* `ropes.html#103 <ropes.html#103>`_
`Letters`:idx: `Letters`:idx:
`strutils.html#103 <strutils.html#103>`_ `strutils.html#103 <strutils.html#103>`_
@ -2520,12 +2595,12 @@ Index
`moveMem`:idx: `moveMem`:idx:
`system.html#417 <system.html#417>`_ `system.html#417 <system.html#417>`_
`multi-methods`:idx:
`tut2.html#104 <tut2.html#104>`_
`Multi-methods`:idx: `Multi-methods`:idx:
`manual.html#213 <manual.html#213>`_ `manual.html#213 <manual.html#213>`_
`multi-methods`:idx:
`tut2.html#104 <tut2.html#104>`_
`MULTIPLE_KEY_FLAG`:idx: `MULTIPLE_KEY_FLAG`:idx:
`mysql.html#127 <mysql.html#127>`_ `mysql.html#127 <mysql.html#127>`_
@ -2562,6 +2637,9 @@ Index
`my_socket`:idx: `my_socket`:idx:
`mysql.html#107 <mysql.html#107>`_ `mysql.html#107 <mysql.html#107>`_
`mySQL`:idx:
`db_mysql.html#101 <db_mysql.html#101>`_
`MYSQL`:idx: `MYSQL`:idx:
`mysql.html#357 <mysql.html#357>`_ `mysql.html#357 <mysql.html#357>`_
@ -3049,12 +3127,12 @@ Index
`nan`:idx: `nan`:idx:
`system.html#440 <system.html#440>`_ `system.html#440 <system.html#440>`_
`Natural`:idx:
`system.html#134 <system.html#134>`_
`natural`:idx: `natural`:idx:
`pegs.html#131 <pegs.html#131>`_ `pegs.html#131 <pegs.html#131>`_
`Natural`:idx:
`system.html#134 <system.html#134>`_
`neginf`:idx: `neginf`:idx:
`system.html#439 <system.html#439>`_ `system.html#439 <system.html#439>`_
@ -3122,13 +3200,13 @@ Index
`newIntLitNode`:idx: `newIntLitNode`:idx:
`macros.html#142 <macros.html#142>`_ `macros.html#142 <macros.html#142>`_
`newLine`:idx:
`pegs.html#121 <pegs.html#121>`_
`newline`:idx: `newline`:idx:
* `manual.html#121 <manual.html#121>`_ * `manual.html#121 <manual.html#121>`_
* `pegs.html#120 <pegs.html#120>`_ * `pegs.html#120 <pegs.html#120>`_
`newLine`:idx:
`pegs.html#121 <pegs.html#121>`_
`NewLines`:idx: `NewLines`:idx:
`lexbase.html#102 <lexbase.html#102>`_ `lexbase.html#102 <lexbase.html#102>`_
@ -3158,6 +3236,7 @@ Index
* `parseopt.html#105 <parseopt.html#105>`_ * `parseopt.html#105 <parseopt.html#105>`_
* `parsecfg.html#106 <parsecfg.html#106>`_ * `parsecfg.html#106 <parsecfg.html#106>`_
* `parsexml.html#122 <parsexml.html#122>`_ * `parsexml.html#122 <parsexml.html#122>`_
* `httpserver.html#105 <httpserver.html#105>`_
`nextPowerOfTwo`:idx: `nextPowerOfTwo`:idx:
`math.html#108 <math.html#108>`_ `math.html#108 <math.html#108>`_
@ -3237,21 +3316,27 @@ Index
`ONLY_KILL_QUERY`:idx: `ONLY_KILL_QUERY`:idx:
`mysql.html#189 <mysql.html#189>`_ `mysql.html#189 <mysql.html#189>`_
`Open`:idx:
* `system.html#507 <system.html#507>`_
* `system.html#508 <system.html#508>`_
`open`:idx: `open`:idx:
* `lexbase.html#104 <lexbase.html#104>`_ * `lexbase.html#104 <lexbase.html#104>`_
* `parsecfg.html#104 <parsecfg.html#104>`_ * `parsecfg.html#104 <parsecfg.html#104>`_
* `parsexml.html#107 <parsexml.html#107>`_ * `parsexml.html#107 <parsexml.html#107>`_
* `parsecsv.html#106 <parsecsv.html#106>`_ * `parsecsv.html#106 <parsecsv.html#106>`_
* `zipfiles.html#102 <zipfiles.html#102>`_ * `zipfiles.html#102 <zipfiles.html#102>`_
* `httpserver.html#103 <httpserver.html#103>`_
`Open`:idx:
* `system.html#507 <system.html#507>`_
* `system.html#508 <system.html#508>`_
* `db_postgres.html#118 <db_postgres.html#118>`_
* `db_mysql.html#118 <db_mysql.html#118>`_
`openarray`:idx: `openarray`:idx:
* `tut1.html#119 <tut1.html#119>`_ * `tut1.html#119 <tut1.html#119>`_
* `system.html#130 <system.html#130>`_ * `system.html#130 <system.html#130>`_
`openDefaultBrowser`:idx:
`browsers.html#101 <browsers.html#101>`_
`OpenFile`:idx: `OpenFile`:idx:
* `system.html#505 <system.html#505>`_ * `system.html#505 <system.html#505>`_
* `system.html#506 <system.html#506>`_ * `system.html#506 <system.html#506>`_
@ -3279,12 +3364,12 @@ Index
`ord`:idx: `ord`:idx:
`system.html#182 <system.html#182>`_ `system.html#182 <system.html#182>`_
`Ordinal`:idx:
`system.html#114 <system.html#114>`_
`ordinal`:idx: `ordinal`:idx:
`tut1.html#114 <tut1.html#114>`_ `tut1.html#114 <tut1.html#114>`_
`Ordinal`:idx:
`system.html#114 <system.html#114>`_
`Ordinal types`:idx: `Ordinal types`:idx:
`manual.html#142 <manual.html#142>`_ `manual.html#142 <manual.html#142>`_
@ -3321,6 +3406,12 @@ Index
`parentDir`:idx: `parentDir`:idx:
`os.html#127 <os.html#127>`_ `os.html#127 <os.html#127>`_
`parseBiggestFloat`:idx:
`parseutils.html#110 <parseutils.html#110>`_
`parseBiggestInt`:idx:
`parseutils.html#108 <parseutils.html#108>`_
`ParseBiggestInt`:idx: `ParseBiggestInt`:idx:
`strutils.html#143 <strutils.html#143>`_ `strutils.html#143 <strutils.html#143>`_
@ -3330,12 +3421,27 @@ Index
`ParseFloat`:idx: `ParseFloat`:idx:
`strutils.html#144 <strutils.html#144>`_ `strutils.html#144 <strutils.html#144>`_
`parseFloat`:idx:
`parseutils.html#111 <parseutils.html#111>`_
`parseHex`:idx:
`parseutils.html#101 <parseutils.html#101>`_
`ParseHexInt`:idx: `ParseHexInt`:idx:
`strutils.html#145 <strutils.html#145>`_ `strutils.html#145 <strutils.html#145>`_
`parseIdent`:idx:
`parseutils.html#103 <parseutils.html#103>`_
`ParseInt`:idx: `ParseInt`:idx:
`strutils.html#142 <strutils.html#142>`_ `strutils.html#142 <strutils.html#142>`_
`parseInt`:idx:
`parseutils.html#109 <parseutils.html#109>`_
`parseOct`:idx:
`parseutils.html#102 <parseutils.html#102>`_
`ParseOctInt`:idx: `ParseOctInt`:idx:
`strutils.html#159 <strutils.html#159>`_ `strutils.html#159 <strutils.html#159>`_
@ -3345,6 +3451,9 @@ Index
`parseSQL`:idx: `parseSQL`:idx:
`parsesql.html#109 <parsesql.html#109>`_ `parsesql.html#109 <parsesql.html#109>`_
`parseToken`:idx:
`parseutils.html#104 <parseutils.html#104>`_
`PART_KEY_FLAG`:idx: `PART_KEY_FLAG`:idx:
`mysql.html#138 <mysql.html#138>`_ `mysql.html#138 <mysql.html#138>`_
@ -3592,9 +3701,21 @@ Index
`pop`:idx: `pop`:idx:
`system.html#477 <system.html#477>`_ `system.html#477 <system.html#477>`_
`port`:idx:
`httpserver.html#104 <httpserver.html#104>`_
`Positive`:idx: `Positive`:idx:
`system.html#135 <system.html#135>`_ `system.html#135 <system.html#135>`_
`post`:idx:
`httpclient.html#109 <httpclient.html#109>`_
`postContent`:idx:
`httpclient.html#110 <httpclient.html#110>`_
`PostgreSQL`:idx:
`db_postgres.html#101 <db_postgres.html#101>`_
`pow`:idx: `pow`:idx:
`math.html#132 <math.html#132>`_ `math.html#132 <math.html#132>`_
@ -3650,6 +3771,9 @@ Index
`programming by contracts`:idx: `programming by contracts`:idx:
`system.html#423 <system.html#423>`_ `system.html#423 <system.html#423>`_
`PRope`:idx:
`ropes.html#102 <ropes.html#102>`_
`Psockaddr`:idx: `Psockaddr`:idx:
`mysql.html#250 <mysql.html#250>`_ `mysql.html#250 <mysql.html#250>`_
@ -3758,6 +3882,14 @@ Index
`q`:idx: `q`:idx:
`xmlgen.html#160 <xmlgen.html#160>`_ `xmlgen.html#160 <xmlgen.html#160>`_
`Query`:idx:
* `db_postgres.html#109 <db_postgres.html#109>`_
* `db_mysql.html#109 <db_mysql.html#109>`_
`QueryAffectedRows`:idx:
* `db_postgres.html#116 <db_postgres.html#116>`_
* `db_mysql.html#116 <db_mysql.html#116>`_
`quit`:idx: `quit`:idx:
* `system.html#497 <system.html#497>`_ * `system.html#497 <system.html#497>`_
* `system.html#498 <system.html#498>`_ * `system.html#498 <system.html#498>`_
@ -3941,6 +4073,9 @@ Index
`repr`:idx: `repr`:idx:
`system.html#379 <system.html#379>`_ `system.html#379 <system.html#379>`_
`request`:idx:
`httpclient.html#106 <httpclient.html#106>`_
`ResetAttributes`:idx: `ResetAttributes`:idx:
`terminal.html#110 <terminal.html#110>`_ `terminal.html#110 <terminal.html#110>`_
@ -3957,9 +4092,22 @@ Index
`reURL`:idx: `reURL`:idx:
`regexprs.html#120 <regexprs.html#120>`_ `regexprs.html#120 <regexprs.html#120>`_
`rope`:idx:
* `ropes.html#101 <ropes.html#101>`_
* `ropes.html#104 <ropes.html#104>`_
* `ropes.html#105 <ropes.html#105>`_
* `ropes.html#106 <ropes.html#106>`_
`round`:idx: `round`:idx:
`math.html#121 <math.html#121>`_ `math.html#121 <math.html#121>`_
`Rows`:idx:
* `db_postgres.html#112 <db_postgres.html#112>`_
* `db_mysql.html#112 <db_mysql.html#112>`_
`run`:idx:
`httpserver.html#107 <httpserver.html#107>`_
`runeAt`:idx: `runeAt`:idx:
`unicode.html#109 <unicode.html#109>`_ `unicode.html#109 <unicode.html#109>`_
@ -4138,6 +4286,15 @@ Index
`sizeof`:idx: `sizeof`:idx:
`system.html#168 <system.html#168>`_ `system.html#168 <system.html#168>`_
`skip`:idx:
`parseutils.html#106 <parseutils.html#106>`_
`skipIgnoreCase`:idx:
`parseutils.html#107 <parseutils.html#107>`_
`skipWhitespace`:idx:
`parseutils.html#105 <parseutils.html#105>`_
`sleep`:idx: `sleep`:idx:
`os.html#170 <os.html#170>`_ `os.html#170 <os.html#170>`_
@ -4179,6 +4336,9 @@ Index
* `strutils.html#130 <strutils.html#130>`_ * `strutils.html#130 <strutils.html#130>`_
* `strutils.html#131 <strutils.html#131>`_ * `strutils.html#131 <strutils.html#131>`_
`sql`:idx:
`db_postgres.html#106 <db_postgres.html#106>`_
`sqlite3_aggregate_context`:idx: `sqlite3_aggregate_context`:idx:
`sqlite3.html#261 <sqlite3.html#261>`_ `sqlite3.html#261 <sqlite3.html#261>`_
@ -5059,6 +5219,10 @@ Index
`td`:idx: `td`:idx:
`xmlgen.html#172 <xmlgen.html#172>`_ `xmlgen.html#172 <xmlgen.html#172>`_
`TDbConn`:idx:
* `db_postgres.html#102 <db_postgres.html#102>`_
* `db_mysql.html#102 <db_mysql.html#102>`_
`template`:idx: `template`:idx:
`manual.html#220 <manual.html#220>`_ `manual.html#220 <manual.html#220>`_
@ -5120,6 +5284,9 @@ Index
`thead`:idx: `thead`:idx:
`xmlgen.html#176 <xmlgen.html#176>`_ `xmlgen.html#176 <xmlgen.html#176>`_
`THeader`:idx:
`httpclient.html#102 <httpclient.html#102>`_
`TimeInfoToTime`:idx: `TimeInfoToTime`:idx:
`times.html#108 <times.html#108>`_ `times.html#108 <times.html#108>`_
@ -5239,9 +5406,16 @@ Index
`TRequestMethod`:idx: `TRequestMethod`:idx:
`cgi.html#105 <cgi.html#105>`_ `cgi.html#105 <cgi.html#105>`_
`TResponse`:idx:
`httpclient.html#101 <httpclient.html#101>`_
`TResult`:idx: `TResult`:idx:
`system.html#167 <system.html#167>`_ `system.html#167 <system.html#167>`_
`TRow`:idx:
* `db_postgres.html#103 <db_postgres.html#103>`_
* `db_mysql.html#103 <db_mysql.html#103>`_
`TRune`:idx: `TRune`:idx:
`unicode.html#101 <unicode.html#101>`_ `unicode.html#101 <unicode.html#101>`_
@ -5255,6 +5429,17 @@ Index
* `manual.html#194 <manual.html#194>`_ * `manual.html#194 <manual.html#194>`_
* `tut2.html#108 <tut2.html#108>`_ * `tut2.html#108 <tut2.html#108>`_
`TryInsertID`:idx:
* `db_postgres.html#114 <db_postgres.html#114>`_
* `db_mysql.html#114 <db_mysql.html#114>`_
`TryQuery`:idx:
* `db_postgres.html#108 <db_postgres.html#108>`_
* `db_mysql.html#108 <db_mysql.html#108>`_
`TServer`:idx:
`httpserver.html#102 <httpserver.html#102>`_
`Tsqlite3_callback`:idx: `Tsqlite3_callback`:idx:
`sqlite3.html#182 <sqlite3.html#182>`_ `sqlite3.html#182 <sqlite3.html#182>`_
@ -5279,6 +5464,10 @@ Index
`TSqlParser`:idx: `TSqlParser`:idx:
`parsesql.html#106 <parsesql.html#106>`_ `parsesql.html#106 <parsesql.html#106>`_
`TSqlQuery`:idx:
* `db_postgres.html#105 <db_postgres.html#105>`_
* `db_mysql.html#105 <db_mysql.html#105>`_
`TStream`:idx: `TStream`:idx:
`streams.html#102 <streams.html#102>`_ `streams.html#102 <streams.html#102>`_
@ -5426,12 +5615,12 @@ Index
`validIdentifier`:idx: `validIdentifier`:idx:
`strutils.html#164 <strutils.html#164>`_ `strutils.html#164 <strutils.html#164>`_
`Var`:idx:
`manual.html#187 <manual.html#187>`_
`var`:idx: `var`:idx:
`xmlgen.html#181 <xmlgen.html#181>`_ `xmlgen.html#181 <xmlgen.html#181>`_
`Var`:idx:
`manual.html#187 <manual.html#187>`_
`varargs`:idx: `varargs`:idx:
`manual.html#251 <manual.html#251>`_ `manual.html#251 <manual.html#251>`_
@ -5477,12 +5666,12 @@ Index
`while`:idx: `while`:idx:
`manual.html#203 <manual.html#203>`_ `manual.html#203 <manual.html#203>`_
`Whitespace`:idx:
`strutils.html#102 <strutils.html#102>`_
`whitespace`:idx: `whitespace`:idx:
`pegs.html#127 <pegs.html#127>`_ `pegs.html#127 <pegs.html#127>`_
`Whitespace`:idx:
`strutils.html#102 <strutils.html#102>`_
`winTimeToUnixTime`:idx: `winTimeToUnixTime`:idx:
`times.html#118 <times.html#118>`_ `times.html#118 <times.html#118>`_
@ -5496,6 +5685,7 @@ Index
* `system.html#521 <system.html#521>`_ * `system.html#521 <system.html#521>`_
* `streams.html#103 <streams.html#103>`_ * `streams.html#103 <streams.html#103>`_
* `streams.html#104 <streams.html#104>`_ * `streams.html#104 <streams.html#104>`_
* `ropes.html#118 <ropes.html#118>`_
`writeBuffer`:idx: `writeBuffer`:idx:
`system.html#531 <system.html#531>`_ `system.html#531 <system.html#531>`_
@ -5516,6 +5706,9 @@ Index
`WriteStyled`:idx: `WriteStyled`:idx:
`terminal.html#112 <terminal.html#112>`_ `terminal.html#112 <terminal.html#112>`_
`wwwNL`:idx:
`httpserver.html#101 <httpserver.html#101>`_
`XML`:idx: `XML`:idx:
* `parsexml.html#101 <parsexml.html#101>`_ * `parsexml.html#101 <parsexml.html#101>`_
* `xmlgen.html#101 <xmlgen.html#101>`_ * `xmlgen.html#101 <xmlgen.html#101>`_

View file

@ -1,95 +0,0 @@
#
#
# Nimrod's Runtime Library
# (c) Copyright 2010 Dominik Picheta
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## Parses & constructs URLs.
import strutils
type
TURL* = tuple[ ## represents a *Uniform Resource Locator* (URL)
## any optional component is "" if it does not exist
scheme, username, password,
hostname, port, path, query, anchor: string]
proc parse*(url: string): TURL =
var i: int = 0
var scheme, username, password: string = ""
var hostname, port, path, query, anchor: string = ""
var temp: string = ""
if url[i] != '/': #url isn't a relative path
while True:
#Scheme
if url[i] == ':':
if url[i+1] == '/' and url[i+2] == '/':
scheme = temp
temp = ""
inc(i, 3) #Skip the //
#Authority(username, password)
if url[i] == '@':
username = temp.split(':')[0]
if temp.split(':').len() > 1:
password = temp.split(':')[1]
temp = ""
inc(i) #Skip the @
#hostname(subdomain, domain, port)
if url[i] == '/' or url[i] == '\0':
#TODO
hostname = temp
if hostname.split(':').len() > 1:
port = hostname.split(':')[1]
hostname = hostname.split(':')[0]
temp = ""
break
temp.add(url[i])
inc(i)
#Path
while True:
if url[i] == '?':
path = temp
temp = ""
if url[i] == '#':
if temp[0] == '?':
query = temp
else:
path = temp
temp = ""
if url[i] == '\0':
if temp[0] == '?':
query = temp
elif temp[0] == '#':
anchor = temp
else:
path = temp
break
temp.add(url[i])
inc(i)
return (scheme, username, password, hostname, port, path, query, anchor)
proc `$`*(t: TURL): string =
result = ""
if t.scheme != "": result.add(t.scheme & "://")
if t.username != "":
if t.password != "":
result.add(t.username & ":" & t.password & "@")
else:
result.add(t.username & "@")
if t.hostname != "": result.add(t.hostname)
if t.port != "": result.add(":" & t.port)
if t.path != "": result.add(t.path)
if t.query != "": result.add(t.query)
if t.anchor != "": result.add(t.anchor)

View file

@ -9,21 +9,55 @@
## This module implements a simple HTTP client that can be used to retrieve ## This module implements a simple HTTP client that can be used to retrieve
## webpages/other data. ## webpages/other data.
##
## Retrieving a website
## ====================
##
## This example uses HTTP GET to retrieve
## ``http://google.com``
##
## .. code-block:: nimrod
## echo(getContent("http://google.com"))
##
## Using HTTP POST
## ===============
##
## This example demonstrates the usage of the W3 HTML Validator, it
## uses ``multipart/form-data`` as the ``Content-Type`` to send the HTML to
## the server.
##
## .. code-block:: nimrod
## var headers: string = "Content-Type: multipart/form-data; boundary=xyz\c\L"
## var body: string = "--xyz\c\L"
## # soap 1.2 output
## body.add("Content-Disposition: form-data; name=\"output\"\c\L")
## body.add("\c\Lsoap12\c\L")
##
## # html
## body.add("--xyz\c\L")
## body.add("Content-Disposition: form-data; name=\"uploaded_file\";" &
## " filename=\"test.html\"\c\L")
## body.add("Content-Type: text/html\c\L")
## body.add("\c\L<html><head></head><body><p>test</p></body></html>\c\L")
## body.add("--xyz--")
##
## echo(postContent("http://validator.w3.org/check", headers, body))
# neuer Code: import sockets, strutils, parseurl, pegs, parseutils, strtabs
import sockets, strutils, parseurl, pegs, parseutils
type type
TResponse* = tuple[ TResponse* = tuple[
version: string, status: string, headers: seq[THeader], version: string,
status: string,
headers: PStringTable,
body: string] body: string]
THeader* = tuple[htype, hvalue: string]
EInvalidProtocol* = object of EBase ## exception that is raised when server EInvalidProtocol* = object of EBase ## exception that is raised when server
## does not conform to the implemented ## does not conform to the implemented
## protocol ## protocol
EHttpRequestErr* = object of EBase ## Thrown in the ``getContent`` proc, EHttpRequestErr* = object of EBase ## Thrown in the ``getContent`` proc
## and ``postContent`` proc,
## when the server returns an error ## when the server returns an error
template newException(exceptn, message: expr): expr = template newException(exceptn, message: expr): expr =
@ -46,14 +80,6 @@ proc fileError(msg: string) =
e.msg = msg e.msg = msg
raise e raise e
proc getHeaderValue*(headers: seq[THeader], name: string): string =
## Retrieves a header by ``name``, from ``headers``.
## Returns "" if a header is not found
for i in low(headers)..high(headers):
if cmpIgnoreCase(headers[i].htype, name) == 0:
return headers[i].hvalue
return ""
proc charAt(d: var string, i: var int, s: TSocket): char {.inline.} = proc charAt(d: var string, i: var int, s: TSocket): char {.inline.} =
result = d[i] result = d[i]
while result == '\0': while result == '\0':
@ -111,14 +137,14 @@ proc parseChunks(d: var string, start: int, s: TSocket): string =
while charAt(d, i, s) in {'\C', '\L'}: inc(i) while charAt(d, i, s) in {'\C', '\L'}: inc(i)
proc parseBody(d: var string, start: int, s: TSocket, proc parseBody(d: var string, start: int, s: TSocket,
headers: seq[THeader]): string = headers: PStringTable): string =
if getHeaderValue(headers, "Transfer-Encoding") == "chunked": if headers["Transfer-Encoding"] == "chunked":
result = parseChunks(d, start, s) result = parseChunks(d, start, s)
else: else:
result = copy(d, start) result = copy(d, start)
# -REGION- Content-Length # -REGION- Content-Length
# (http://tools.ietf.org/html/rfc2616#section-4.4) NR.3 # (http://tools.ietf.org/html/rfc2616#section-4.4) NR.3
var contentLengthHeader = getHeaderValue(headers, "Content-Length") var contentLengthHeader = headers["Content-Length"]
if contentLengthHeader != "": if contentLengthHeader != "":
var length = contentLengthHeader.parseint() var length = contentLengthHeader.parseint()
while result.len() < length: result.add(s.recv()) while result.len() < length: result.add(s.recv())
@ -127,7 +153,7 @@ proc parseBody(d: var string, start: int, s: TSocket,
# -REGION- Connection: Close # -REGION- Connection: Close
# (http://tools.ietf.org/html/rfc2616#section-4.4) NR.5 # (http://tools.ietf.org/html/rfc2616#section-4.4) NR.5
if getHeaderValue(headers, "Connection") == "close": if headers["Connection"] == "close":
while True: while True:
var moreData = recv(s) var moreData = recv(s)
if moreData.len == 0: break if moreData.len == 0: break
@ -154,7 +180,7 @@ proc parseResponse(s: TSocket): TResponse =
# Everything after the first line leading up to the body # Everything after the first line leading up to the body
# htype: hvalue # htype: hvalue
result.headers = @[] result.headers = newStringTable(modeCaseInsensitive)
while true: while true:
var key = "" var key = ""
while d[i] != ':': while d[i] != ':':
@ -168,7 +194,7 @@ proc parseResponse(s: TSocket): TResponse =
val.add(d[i]) val.add(d[i])
inc(i) inc(i)
result.headers.add((key, val)) result.headers[key] = val
if d[i] == '\C': inc(i) if d[i] == '\C': inc(i)
if d[i] == '\L': inc(i) if d[i] == '\L': inc(i)
@ -181,22 +207,46 @@ proc parseResponse(s: TSocket): TResponse =
result.body = parseBody(d, i, s, result.headers) result.body = parseBody(d, i, s, result.headers)
proc request*(url: string): TResponse = type
var r = parse(url) THttpMethod* = enum ## the requested HttpMethod
httpHEAD, ## Asks for the response identical to the one that would
## correspond to a GET request, but without the response
## body.
httpGET, ## Retrieves the specified resource.
httpPOST, ## Submits data to be processed to the identified
## resource. The data is included in the body of the
## request.
httpPUT, ## Uploads a representation of the specified resource.
httpDELETE, ## Deletes the specified resource.
httpTRACE, ## Echoes back the received request, so that a client
## can see what intermediate servers are adding or
## changing in the request.
httpOPTIONS, ## Returns the HTTP methods that the server supports
## for specified address.
httpCONNECT ## Converts the request connection to a transparent
## TCP/IP tunnel, usually used for proxies.
var headers: string proc request*(url: string, httpMethod = httpGET, extraHeaders = "",
body = ""): TResponse =
## | Requests ``url`` with the specified ``httpMethod``.
## | Extra headers can be specified and must be seperated by ``\c\L``
var r = parseUrl(url)
var headers = copy($httpMethod, len("http"))
if r.path != "": if r.path != "":
headers = "GET " & r.path & " HTTP/1.1\c\L" headers.add(" " & r.path & r.query)
else: headers.add(" / HTTP/1.1\c\L")
headers = "GET / HTTP/1.1\c\L"
add(headers, "Host: " & r.hostname & "\c\L\c\L") add(headers, "Host: " & r.hostname & "\c\L")
add(headers, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; pl;" & add(headers, extraHeaders)
" rv:1.9.2) Gecko/20100115 Firefox/3.6") add(headers, "\c\L")
var s = socket() var s = socket()
s.connect(r.hostname, TPort(80)) s.connect(r.hostname, TPort(80))
s.send(headers) s.send(headers)
if body != "":
s.send(body)
result = parseResponse(s) result = parseResponse(s)
s.close() s.close()
@ -207,24 +257,49 @@ proc redirection(status: string): bool =
return True return True
proc get*(url: string, maxRedirects = 5): TResponse = proc get*(url: string, maxRedirects = 5): TResponse =
## low-level proc similar to ``request`` which handles redirection ## | GET's the ``url`` and returns a ``TResponse`` object
## | This proc also handles redirection
result = request(url) result = request(url)
for i in 1..maxRedirects: for i in 1..maxRedirects:
if result.status.redirection(): if result.status.redirection():
var locationHeader = getHeaderValue(result.headers, "Location") var locationHeader = result.headers["Location"]
if locationHeader == "": httpError("location header expected") if locationHeader == "": httpError("location header expected")
result = request(locationHeader) result = request(locationHeader)
proc getContent*(url: string): string = proc getContent*(url: string): string =
## GET's the body and returns it as a string ## | GET's the body and returns it as a string.
## Raises exceptions for the status codes ``4xx`` and ``5xx`` ## | Raises exceptions for the status codes ``4xx`` and ``5xx``
var r = get(url) var r = get(url)
if r.status[0] in {'4','5'}: if r.status[0] in {'4','5'}:
raise newException(EHTTPRequestErr, r.status) raise newException(EHTTPRequestErr, r.status)
else: else:
return r.body return r.body
proc post*(url: string, extraHeaders = "", body = "",
maxRedirects = 5): TResponse =
## | POST's ``body`` to the ``url`` and returns a ``TResponse`` object.
## | This proc adds the necessary Content-Length header.
## | This proc also handles redirection.
extraHeaders.add("Content-Length: " & $len(body) & "\c\L")
result = request(url, httpPOST, extraHeaders, body)
for i in 1..maxRedirects:
if result.status.redirection():
var locationHeader = result.headers["Location"]
if locationHeader == "": httpError("location header expected")
var meth = if result.status != "307": httpGet else: httpPost
result = request(locationHeader, meth, extraHeaders, body)
proc postContent*(url: string, extraHeaders = "", body = ""): string =
## | POST's ``body`` to ``url`` and returns the response's body as a string
## | Raises exceptions for the status codes ``4xx`` and ``5xx``
var r = post(url, extraHeaders, body)
if r.status[0] in {'4','5'}:
raise newException(EHTTPRequestErr, r.status)
else:
return r.body
proc downloadFile*(url: string, outputFilename: string) = proc downloadFile*(url: string, outputFilename: string) =
## Downloads ``url`` and saves it to ``outputFilename``
var f: TFile var f: TFile
if open(f, outputFilename, fmWrite): if open(f, outputFilename, fmWrite):
f.write(getContent(url)) f.write(getContent(url))
@ -236,5 +311,24 @@ proc downloadFile*(url: string, outputFilename: string) =
when isMainModule: when isMainModule:
#downloadFile("http://force7.de/nimrod/index.html", "nimrodindex.html") #downloadFile("http://force7.de/nimrod/index.html", "nimrodindex.html")
#downloadFile("http://www.httpwatch.com/", "ChunkTest.html") #downloadFile("http://www.httpwatch.com/", "ChunkTest.html")
downloadFile("http://www.httpwatch.com/httpgallery/chunked/", "ChunkTest.html") #downloadFile("http://validator.w3.org/check?uri=http%3A%2F%2Fgoogle.com",
# "validator.html")
#var r = get("http://validator.w3.org/check?uri=http%3A%2F%2Fgoogle.com&
# charset=%28detect+automatically%29&doctype=Inline&group=0")
var headers: string = "Content-Type: multipart/form-data; boundary=xyz\c\L"
var body: string = "--xyz\c\L"
# soap 1.2 output
body.add("Content-Disposition: form-data; name=\"output\"\c\L")
body.add("\c\Lsoap12\c\L")
# html
body.add("--xyz\c\L")
body.add("Content-Disposition: form-data; name=\"uploaded_file\";" &
" filename=\"test.html\"\c\L")
body.add("Content-Type: text/html\c\L")
body.add("\c\L<html><head></head><body><p>test</p></body></html>\c\L")
body.add("--xyz--")
echo(postContent("http://validator.w3.org/check", headers, body))

View file

@ -1,18 +1,95 @@
import regexprs, strutils #
#
# Nimrod's Runtime Library
# (c) Copyright 2010 Dominik Picheta
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## Parses & constructs URLs.
import strutils
type type
TUrl* = tuple[protocol, subdomain, domain, port: string, path: seq[string]] TURL* = tuple[ ## represents a *Uniform Resource Locator* (URL)
## any optional component is "" if it does not exist
scheme, username, password,
hostname, port, path, query, anchor: string]
proc parseUrl*(url: string): TUrl = proc parseUrl*(url: string): TURL =
#([a-zA-Z]+://)?(\w+?\.)?(\w+)(\.\w+)(:[0-9]+)?(/.+)? var i: int = 0
const pattern = r"([a-zA-Z]+://)?(\w+?\.)?(\w+)(\.\w+)(:[0-9]+)?(/.+)?"
var m: array[0..6, string] #Array with the matches
discard regexprs.match(url, pattern, m)
result = (protocol: m[1], subdomain: m[2], domain: m[3] & m[4], var scheme, username, password: string = ""
port: m[5], path: m[6].split('/')) var hostname, port, path, query, anchor: string = ""
when isMainModule: var temp: string = ""
var r = parseUrl(r"http://google.com/search?var=bleahdhsad")
echo(r.domain)
if url[i] != '/': #url isn't a relative path
while True:
#Scheme
if url[i] == ':':
if url[i+1] == '/' and url[i+2] == '/':
scheme = temp
temp = ""
inc(i, 3) #Skip the //
#Authority(username, password)
if url[i] == '@':
username = temp.split(':')[0]
if temp.split(':').len() > 1:
password = temp.split(':')[1]
temp = ""
inc(i) #Skip the @
#hostname(subdomain, domain, port)
if url[i] == '/' or url[i] == '\0':
#TODO
hostname = temp
if hostname.split(':').len() > 1:
port = hostname.split(':')[1]
hostname = hostname.split(':')[0]
temp = ""
break
temp.add(url[i])
inc(i)
#Path
while True:
if url[i] == '?':
path = temp
temp = ""
if url[i] == '#':
if temp[0] == '?':
query = temp
else:
path = temp
temp = ""
if url[i] == '\0':
if temp[0] == '?':
query = temp
elif temp[0] == '#':
anchor = temp
else:
path = temp
break
temp.add(url[i])
inc(i)
return (scheme, username, password, hostname, port, path, query, anchor)
proc `$`*(t: TURL): string =
result = ""
if t.scheme != "": result.add(t.scheme & "://")
if t.username != "":
if t.password != "":
result.add(t.username & ":" & t.password & "@")
else:
result.add(t.username & "@")
if t.hostname != "": result.add(t.hostname)
if t.port != "": result.add(":" & t.port)
if t.path != "": result.add(t.path)
if t.query != "": result.add(t.query)
if t.anchor != "": result.add(t.anchor)

View file

@ -1486,9 +1486,9 @@ proc dirRaw(p: var TRstParser): PRstNode =
# latex # latex
result = parseDirective(p, {hasOptions, hasArg, argIsWord}) result = parseDirective(p, {hasOptions, hasArg, argIsWord})
if result.sons[0] != nil: if result.sons[0] != nil:
if cmpIgnoreCase(result.sons[0].text, "html") == 0: if cmpIgnoreCase(result.sons[0].sons[0].text, "html") == 0:
dirRawAux(p, result, rnRawHtml, parseLiteralBlock) dirRawAux(p, result, rnRawHtml, parseLiteralBlock)
elif cmpIgnoreCase(result.sons[0].text, "latex") == 0: elif cmpIgnoreCase(result.sons[0].sons[0].text, "latex") == 0:
dirRawAux(p, result, rnRawLatex, parseLiteralBlock) dirRawAux(p, result, rnRawLatex, parseLiteralBlock)
else: else:
rstMessage(p, errInvalidDirectiveX, result.sons[0].text) rstMessage(p, errInvalidDirectiveX, result.sons[0].text)

View file

@ -1,7 +1,7 @@
# #
# #
# Nimrod Website Generator # Nimrod Website Generator
# (c) Copyright 2009 Andreas Rumpf # (c) Copyright 2010 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.
@ -41,7 +41,7 @@ include "sunset.tmpl"
# ------------------------- configuration file ------------------------------- # ------------------------- configuration file -------------------------------
const const
Version = "0.6" Version = "0.7"
Usage = "nimweb - Nimrod Website Generator Version " & version & """ Usage = "nimweb - Nimrod Website Generator Version " & version & """
(c) 2009 Andreas Rumpf (c) 2009 Andreas Rumpf
@ -170,7 +170,7 @@ proc buildDoc(c: var TConfigData, destPath: string) =
proc buildPdfDoc(c: var TConfigData, destPath: string) = proc buildPdfDoc(c: var TConfigData, destPath: string) =
if os.execShellCmd("pdflatex -version") != 0: if os.execShellCmd("pdflatex -version") != 0:
echo "pdflatex not found; not PDF documentation generated" echo "pdflatex not found; no PDF documentation generated"
else: else:
for d in items(c.pdf): for d in items(c.pdf):
Exec("nimrod rst2tex $# $#" % [c.nimrodArgs, d]) Exec("nimrod rst2tex $# $#" % [c.nimrodArgs, d])

View file

@ -8,6 +8,11 @@ News
Version 0.8.8 has been released! Get it `here <download.html>`_. Version 0.8.8 has been released! Get it `here <download.html>`_.
.. raw:: html
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/bEHVw_vcp-A&hl=de_DE&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/bEHVw_vcp-A&hl=de_DE&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
Bugfixes Bugfixes
-------- --------
- The Posix version of ``os.copyFile`` has better error handling. - The Posix version of ``os.copyFile`` has better error handling.