ULX

Author Topic: HTTPConnection - Gmod html library - wacked  (Read 3084 times)

0 Members and 1 Guest are viewing this topic.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
HTTPConnection - Gmod html library - wacked
« on: April 27, 2008, 07:44:13 PM »
I've been working on getting Umotd to load a web page from the server.. to be able to parse it like a local file.
Using code I found at http://garrysmod.com/wiki/?title=HTTPConnection , I'm using the following.
Code: [Select]
             local function Umotd_fnCallback( contents, size )
                   if ( contents == nil or contents == "" ) then
                      contents = "Site " .. Umotd_url .. " gave no results within Gmod timeout"
                     end
                     file.Write( "Umotd/".. Ucom .. ".txt", contents )
             end
             http.Get( Umotd_url, "", Umotd_fnCallback )
             Umotd_display = file.Read ( "Umotd/".. Ucom .. ".txt" )
Any URL I pass gives crazy results. It's never fully worked, but has come pretty close at times.
Testing with http://forums.ulyssesmod.net/ , it never seems to return a full page, if anything at all.
I've attempted to assign Umotd_display = contents within the code, but discovered contents was a 'userdata' variable.
To be honest, I'm not sure what that means, or how to use it.

There is a note along with the page link that says it returns truncated pages.
That seems to be true.

My question is, can anyone assist in figuring out a good way for me to grab a page on the server side.
I understand there may be a 8192 byte limit on the read of the page. Right now, I'd be happy to get more than 15 bytes.
« Last Edit: April 27, 2008, 07:46:15 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: HTTPConnection - Gmod html library - wacked
« Reply #1 on: April 28, 2008, 09:31:48 AM »
yes, Garry's HTTP library is broaken somehow, and he refuses to accept that. Every bug report about it has been closed with no change required. I've been playing around with Anders1's port of the LuaSocket instead, and with a few modifications got the http library (and others) to work correctly. I posted the fixed .lua files in the thread.

As for using it with UMotd, the server would have to also be hosting a web server, or have some type of variable pointing to a valid site. In which case it's easier to just tell the HTML control to point to that site (though I suppose that kills your dynamic variables).

I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: HTTPConnection - Gmod html library - wacked
« Reply #2 on: April 28, 2008, 05:20:25 PM »
Thanks spbogie. I'll have to look into the thread.
As for the client side html control, yes, that may be what I end up having to do if I find no other way to load on the server side.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: HTTPConnection - Gmod html library - wacked
« Reply #3 on: April 30, 2008, 05:47:01 PM »
I've decided to not use LuaSockets. It would be just one more dependency that I don't wish to force on people.
I'm planning on just using client panel, no dynamics.
I'm already considering removing the ULib dependency. THough my original release last year relied heavily, I only use a few of the commands from Ulib now.
With all the latest "Simple MOTD" releases on Facepunch as of late, I'm considering going more public. I figure if ULib isn't required, thats yet a few more users who might grow to like our (Team Ulysses) products, and might actually want to explore ULib.
Hey, I can dream big for us. :P
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming