HTTPConnection
From GMod Wiki
Use HTTPGet or Http.Get to get an HTTPConnection object.
Object Methods
HTTPConnection:__gc
HTTPConnection:__index
HTTPConnection:Download
HTTPConnection:DownloadSize
HTTPConnection:Finished
HTTPConnection:GetBuffer
Additional Notes
- It's easier to use the http library as shown in the link below.
- Here is an example on how to use the http library:
local function fnCallback( contents, size ) if ( contents == nil || contents == "" ) then return end file.Write( "example.txt", contents ); end http.Get( "http://www.example.com/", "", fnCallback );
- That will output the HTML code from www.example.com into example.txt in your data directory.
- Note: All downloaded content seems to be truncated to a random length. Bug?
- For an instant HTTP get with no callback, you can use this:
// Thank Wizzard for this :) function DownloadFile(URL, Headers) local connection = HTTPGet() connection:Download(URL,Headers) debug.sethook() repeat until connection:Finished() return connection:GetBuffer() end local source = DownloadFile("http://google.com")
Please note that when using this method the game will temporarily crash.