Difference between revisions of "Http.get"

From MiniScript Wiki
Jump to navigation Jump to search
(added new headers parameter)
(added note about forbidden headers)
 
Line 13: Line 13:
  
 
=== Usage Notes ===
 
=== Usage Notes ===
 +
When specifying headers, certain headers are supplied by the underlying system and may not be overridden.  These include "Host" and "Accept".  Specifying these headers will cause <c>http.get</c> to return a [[null]] result.
 +
 
The type of the value returned depends on the MIME type reported by the server, as follows:
 
The type of the value returned depends on the MIME type reported by the server, as follows:
  
Line 27: Line 29:
 
| any other type || [[RawData]] object
 
| any other type || [[RawData]] object
 
|}
 
|}
 +
  
 
== Example ==
 
== Example ==

Latest revision as of 15:17, 17 September 2021

In Mini Micro, the http.get function returns the contents of a URL using the HTTP protocol. It supports text, images, sounds, and raw binary data.

Arguments

Parameter Name Meaning
url URL of the web page or resource to fetch
headers optional map of HTTP headers

Usage Notes

When specifying headers, certain headers are supplied by the underlying system and may not be overridden. These include "Host" and "Accept". Specifying these headers will cause http.get to return a null result.

The type of the value returned depends on the MIME type reported by the server, as follows:

MIME Type MiniScript Type
image Image object
audio Sound object
text, javascript, xml, or json string
any other type RawData object


Example

The following example, typed on the Mini Micro command line, retrieves and displays Minnie from the MiniScript web site.

view http.get("https://miniscript.org/img/Icon.png")