|
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> |
| 3 | +<head> |
| 4 | +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 5 | +<meta http-equiv="X-UA-Compatible" content="IE=11"/> |
| 6 | +<meta name="generator" content="Doxygen 1.14.0"/> |
| 7 | +<meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 8 | +<title>Retro Rocket OS: HTTP Library</title> |
| 9 | +<link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 10 | +<script type="text/javascript" src="jquery.js"></script> |
| 11 | +<script type="text/javascript" src="dynsections.js"></script> |
| 12 | +<script type="text/javascript" src="clipboard.js"></script> |
| 13 | +<link href="navtree.css" rel="stylesheet" type="text/css"/> |
| 14 | +<script type="text/javascript" src="navtreedata.js"></script> |
| 15 | +<script type="text/javascript" src="navtree.js"></script> |
| 16 | +<script type="text/javascript" src="cookie.js"></script> |
| 17 | +<link href="search/search.css" rel="stylesheet" type="text/css"/> |
| 18 | +<script type="text/javascript" src="search/searchdata.js"></script> |
| 19 | +<script type="text/javascript" src="search/search.js"></script> |
| 20 | +<link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 21 | +<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/> |
| 22 | +<link href="style.css" rel="stylesheet" type="text/css"/> |
| 23 | +</head> |
| 24 | +<body> |
| 25 | +<div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 26 | +<div id="titlearea"> |
| 27 | +<table cellspacing="0" cellpadding="0"> |
| 28 | + <tbody> |
| 29 | + <tr id="projectrow"> |
| 30 | + <td id="projectlogo"><img alt="Logo" src="rr.png"/></td> |
| 31 | + <td id="projectalign"> |
| 32 | + <div id="projectname">Retro Rocket OS |
| 33 | + </div> |
| 34 | + <div id="projectbrief">BASIC-Powered Operating System</div> |
| 35 | + </td> |
| 36 | + </tr> |
| 37 | + </tbody> |
| 38 | +</table> |
| 39 | +</div> |
| 40 | +<!-- end header part --> |
| 41 | +<!-- Generated by Doxygen 1.14.0 --> |
| 42 | +<script type="text/javascript"> |
| 43 | +var searchBox = new SearchBox("searchBox", "search/",'.html'); |
| 44 | +</script> |
| 45 | +<script type="text/javascript"> |
| 46 | +$(function() { codefold.init(); }); |
| 47 | +</script> |
| 48 | +<script type="text/javascript" src="menudata.js"></script> |
| 49 | +<script type="text/javascript" src="menu.js"></script> |
| 50 | +<script type="text/javascript"> |
| 51 | +$(function() { |
| 52 | + initMenu('',true,false,'search.php','Search',true); |
| 53 | + $(function() { init_search(); }); |
| 54 | +}); |
| 55 | +</script> |
| 56 | +<div id="main-nav"></div> |
| 57 | +</div><!-- top --> |
| 58 | +<div id="side-nav" class="ui-resizable side-nav-resizable"> |
| 59 | + <div id="nav-tree"> |
| 60 | + <div id="nav-tree-contents"> |
| 61 | + <div id="nav-sync" class="sync"></div> |
| 62 | + </div> |
| 63 | + </div> |
| 64 | + <div id="splitbar" style="-moz-user-select:none;" |
| 65 | + class="ui-resizable-handle"> |
| 66 | + </div> |
| 67 | +</div> |
| 68 | +<script type="text/javascript"> |
| 69 | +$(function(){initNavTree('http.html','',''); }); |
| 70 | +</script> |
| 71 | +<div id="container"> |
| 72 | +<div id="doc-content"> |
| 73 | +<!-- window showing the filter options --> |
| 74 | +<div id="MSearchSelectWindow" |
| 75 | + onmouseover="return searchBox.OnSearchSelectShow()" |
| 76 | + onmouseout="return searchBox.OnSearchSelectHide()" |
| 77 | + onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| 78 | +</div> |
| 79 | + |
| 80 | +<!-- iframe showing the search results (closed by default) --> |
| 81 | +<div id="MSearchResultsWindow"> |
| 82 | +<div id="MSearchResults"> |
| 83 | +<div class="SRPage"> |
| 84 | +<div id="SRIndex"> |
| 85 | +<div id="SRResults"></div> |
| 86 | +<div class="SRStatus" id="Loading">Loading...</div> |
| 87 | +<div class="SRStatus" id="Searching">Searching...</div> |
| 88 | +<div class="SRStatus" id="NoMatches">No Matches</div> |
| 89 | +</div> |
| 90 | +</div> |
| 91 | +</div> |
| 92 | +</div> |
| 93 | + |
| 94 | +<div><div class="header"> |
| 95 | + <div class="headertitle"><div class="title">HTTP Library </div></div> |
| 96 | +</div><!--header--> |
| 97 | +<div class="contents"> |
| 98 | +<div class="textblock"><div class="fragment"><div class="line">LIBRARY LIB$ + "/http"</div> |
| 99 | +</div><!-- fragment --><p>The HTTP library provides simple URL parsing helpers and minimal client-side HTTP request routines (HTTP/1.0 with <span class="tt">Connection: close</span>). Responses are stored in an internal buffer for later inspection.</p> |
| 100 | +<p>The following publicly documented procedures and functions are available via this library.</p> |
| 101 | +<hr /> |
| 102 | +<h2 class="doxsection"><a class="anchor" id="url-helpers"></a> |
| 103 | +URL helpers</h2> |
| 104 | +<h3 class="doxsection"><a class="anchor" id="fnhttp_url_schemeurl"></a> |
| 105 | +FNhttp_url_scheme$(url$)</h3> |
| 106 | +<p>Return the scheme (e.g. <span class="tt">http</span>, <span class="tt">https</span>, <span class="tt">ws</span>, <span class="tt">wss</span>, <span class="tt">ftp</span>) or an empty string if none.</p> |
| 107 | +<h3 class="doxsection"><a class="anchor" id="fnhttp_url_anchorurl"></a> |
| 108 | +FNhttp_url_anchor$(url$)</h3> |
| 109 | +<p>Return the fragment (text after <span class="tt">#</span>) or an empty string if none.</p> |
| 110 | +<h3 class="doxsection"><a class="anchor" id="fnhttp_url_queryurl"></a> |
| 111 | +FNhttp_url_query$(url$)</h3> |
| 112 | +<p>Return the query string (text after <span class="tt">?</span>, excluding <span class="tt">#…</span>) or an empty string if none.</p> |
| 113 | +<h3 class="doxsection"><a class="anchor" id="fnhttp_url_pathurl"></a> |
| 114 | +FNhttp_url_path$(url$)</h3> |
| 115 | +<p>Return the path component beginning with <span class="tt">/</span>. Returns <span class="tt">/</span> for bare hosts and an empty string if not applicable.</p> |
| 116 | +<h3 class="doxsection"><a class="anchor" id="fnhttp_url_hosturl"></a> |
| 117 | +FNhttp_url_host$(url$)</h3> |
| 118 | +<p>Return the host portion of the authority. Supports IPv4/hostnames and bracketed IPv6. Returns an empty string if not present.</p> |
| 119 | +<h3 class="doxsection"><a class="anchor" id="fnhttp_url_porturl"></a> |
| 120 | +FNhttp_url_port(url$)</h3> |
| 121 | +<p>Return the explicit port if present; otherwise the default for the scheme (<span class="tt">http</span>/<span class="tt">ws</span>=80, <span class="tt">https</span>/<span class="tt">wss</span>=443, <span class="tt">ftp</span>=21). Returns <span class="tt">0</span> if no scheme is recognised and no explicit port is present.</p> |
| 122 | +<h3 class="doxsection"><a class="anchor" id="fnhttp_url_paramurl-key"></a> |
| 123 | +FNhttp_url_param$(url$, key$)</h3> |
| 124 | +<p>Look up a single query parameter value by name. Returns the value if present, an empty string if the key appears with no value, or an empty string if the key is absent.</p> |
| 125 | +<hr /> |
| 126 | +<h2 class="doxsection"><a class="anchor" id="requests"></a> |
| 127 | +Requests</h2> |
| 128 | +<h3 class="doxsection"><a class="anchor" id="prochttp_geturl"></a> |
| 129 | +PROChttp_get(url$)</h3> |
| 130 | +<p>Perform a <span class="tt">GET</span> request to <span class="tt">url$</span>. The full response (headers + body) is captured internally.</p> |
| 131 | +<h3 class="doxsection"><a class="anchor" id="prochttp_headurl"></a> |
| 132 | +PROChttp_head(url$)</h3> |
| 133 | +<p>Perform a <span class="tt">HEAD</span> request. Only headers are expected; body may be empty.</p> |
| 134 | +<h3 class="doxsection"><a class="anchor" id="prochttp_posturl-postdata"></a> |
| 135 | +PROChttp_post(url$, postdata$)</h3> |
| 136 | +<p>Perform a <span class="tt">POST</span> with <span class="tt">postdata$</span> as the raw request body. <span class="tt">Content-Length</span> is set automatically.</p> |
| 137 | +<h3 class="doxsection"><a class="anchor" id="prochttp_puturl-putdata"></a> |
| 138 | +PROChttp_put(url$, putdata$)</h3> |
| 139 | +<p>Perform a <span class="tt">PUT</span> with <span class="tt">putdata$</span> as the raw request body.</p> |
| 140 | +<h3 class="doxsection"><a class="anchor" id="prochttp_patchurl-patchdata"></a> |
| 141 | +PROChttp_patch(url$, patchdata$)</h3> |
| 142 | +<p>Perform a <span class="tt">PATCH</span> with <span class="tt">patchdata$</span> as the raw request body.</p> |
| 143 | +<h3 class="doxsection"><a class="anchor" id="prochttp_deleteurl"></a> |
| 144 | +PROChttp_delete(url$)</h3> |
| 145 | +<p>Perform a <span class="tt">DELETE</span> request.</p> |
| 146 | +<h3 class="doxsection"><a class="anchor" id="prochttp_requestmethod-url-body"></a> |
| 147 | +PROChttp_request(method$, url$, body$)</h3> |
| 148 | +<p>Low-level entry point used by the above helpers. Builds the request line and minimal headers (<span class="tt">Host</span>, <span class="tt">Connection: close</span>, optional <span class="tt">Content-Length</span>) and sends the request over HTTP, or HTTPS when the scheme/port implies HTTPS. The full response is stored for later retrieval.</p> |
| 149 | +<hr /> |
| 150 | +<h2 class="doxsection"><a class="anchor" id="response-access"></a> |
| 151 | +Response access</h2> |
| 152 | +<h3 class="doxsection"><a class="anchor" id="fnhttp_resultpart"></a> |
| 153 | +FNhttp_result$(part$)</h3> |
| 154 | +<p>Return a specific portion of the most recent response. <span class="tt">part$</span> must be one of:</p> |
| 155 | +<ul> |
| 156 | +<li><span class="tt">"body"</span> — response body only</li> |
| 157 | +<li><span class="tt">"headers"</span> — raw header block (status line + header lines, CRLF-delimited)</li> |
| 158 | +<li><span class="tt">"status"</span> — status line (e.g. <span class="tt">HTTP/1.1 200 OK</span>)</li> |
| 159 | +<li><span class="tt">"code"</span> — status code as a string (e.g. <span class="tt">200</span>)</li> |
| 160 | +<li><span class="tt">"reason"</span> — reason phrase (e.g. <span class="tt">OK</span>)</li> |
| 161 | +<li><span class="tt">"header:<name>"</span> — value of a single header (case-insensitive match on <span class="tt"><name></span>). Returns the first occurrence, trimmed of surrounding whitespace.</li> |
| 162 | +</ul> |
| 163 | +<p>If no response is available, or the requested part does not exist, an empty string is returned.</p> |
| 164 | +<hr /> |
| 165 | +<h2 class="doxsection"><a class="anchor" id="example-14"></a> |
| 166 | +Example</h2> |
| 167 | +<div class="fragment"><div class="line">LIBRARY LIB$ + "/http"</div> |
| 168 | +<div class="line"> </div> |
| 169 | +<div class="line">PROChttp_get("http://neuron.brainbox.cc/test.txt")</div> |
| 170 | +<div class="line"> </div> |
| 171 | +<div class="line">PRINT "HTTP status code: "; FNhttp_result$("code")</div> |
| 172 | +<div class="line">PRINT "Response body:"</div> |
| 173 | +<div class="line">PRINT FNhttp_result$("body")</div> |
| 174 | +</div><!-- fragment --><p>This performs a simple <span class="tt">GET</span>, prints the numeric status code, then prints the body. </p> |
| 175 | +</div></div><!-- contents --> |
| 176 | +</div><!-- PageDoc --> |
| 177 | +</div><!-- doc-content --> |
| 178 | +<div id="page-nav" class="page-nav-panel"> |
| 179 | +<div id="page-nav-resize-handle"></div> |
| 180 | +<div id="page-nav-tree"> |
| 181 | +<div id="page-nav-contents"> |
| 182 | +</div><!-- page-nav-contents --> |
| 183 | +</div><!-- page-nav-tree --> |
| 184 | +</div><!-- page-nav --> |
| 185 | +</div><!-- container --> |
| 186 | +<!-- start footer part --> |
| 187 | +<div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> |
| 188 | + <ul> |
| 189 | + <li class="navelem"><a href="index.html">Retro Rocket OS</a></li><li class="navelem"><a href="basic-ref.html">BASIC Language Reference</a></li><li class="navelem"><a href="libraries.html">Libraries</a></li> |
| 190 | + <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li> |
| 191 | + </ul> |
| 192 | +</div> |
| 193 | +</body> |
| 194 | +</html> |
0 commit comments