HTTPConnection

From GMod Wiki

Jump to: navigation, search

Use HTTPGet or Http.Get to get an HTTPConnection object.

Object Methods

NewerShared.png HTTPConnection:__gc
NewerShared.png HTTPConnection:__index
NewerShared.png HTTPConnection:Download
NewerShared.png HTTPConnection:DownloadSize
NewerShared.png HTTPConnection:Finished
NewerShared.png HTTPConnection:GetBuffer

Additional Notes

 
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 );
 
 
// 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.

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox