Garry's Mod Wiki


http.Fetch( string url, function onSuccess = nil, function onFailure = nil, table headers = {} )


Launches a GET request.

HTTP-requests on private networks don't work.
To enable HTTP-requests on private networks use Command Line Parameters -allowlocalhttp


1 string url
The URL of the website to fetch.
2 function onSuccess = nil
Function to be called on success. Arguments are

3 function onFailure = nil
Function to be called on failure. Arguments are

  • string error - The error message
4 table headers = {}
KeyValue table for headers


Shows the typical usage to get the HTML of a webpage.

local TheReturnedHTML = "" -- Blankness http.Fetch( "", function( body, len, headers, code ) -- The first argument is the HTML we asked for. TheReturnedHTML = body end, function( error ) -- We failed. =( end, { -- header exemple ["accept-encoding"] = "gzip, deflate", ["accept-language"] = "fr" } )
Output: If it successfully fetched the page, the variable 'TheReturnedHTML' should contain the returned HTML in plain text.

Page Links

Special Pages



Render Time: 49ms

DB GetPage 3
Generate Html 23
SaveChanges (1) 8
Render Body 0
Render Sidebar 12