Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 42

Thread: anyone managed to use CreateHTTPRequest?

  1. #1

    anyone managed to use CreateHTTPRequest?

    I have tried almost every implementation of this I can think of and have got none to work.

    If anyone has a working example I would be very grateful if someone could share so I can see if I'm doing anything wrong
    https://github.com/ThePianoDentist/t...dentistdotabot Lina bot which pulls small camp when 'laning' (Aim to work on pulling and stacking bots initially)
    https://github.com/ThePianoDentist/dotabots-ml-tools Parsing data from bot games

  2. #2
    think I found my issue


    FmtStrVSNPrintf truncated to 256 without QUIET_TRUNCATION specified! String
    "http://localhost/:9200/doublepull/run?{"type":"parameter_values","values":{"damage_s pread_lane":0,"damage_spread_neutral":0,"fraction_ lane_left":0,"fraction_neutral_left":1.25,"hero_at tackdamage":53,"hero_attackrange":670,"hero_attack speed":1.20000004768"

    whilst doing
    Code:
    CreateHTTPRequest(":9200/doublepull/run?" ..tostring(JSON:encode(data)))
    so a) you cannot specify a port as the method hard-codes a slash after localhost
    b) it appears you can only send very, very short snippets of data. max length 256

    edit: I have no idea how I saw these errors. 99/100 times it just fails silently. guess I just got lucky 0_o
    Last edited by TheP1anoDentist; 03-11-2017 at 12:34 PM.
    https://github.com/ThePianoDentist/t...dentistdotabot Lina bot which pulls small camp when 'laning' (Aim to work on pulling and stacking bots initially)
    https://github.com/ThePianoDentist/dotabots-ml-tools Parsing data from bot games

  3. #3
    ...well still doesn't work.

    the exact string I am giving to CreateHTTPRequest is doublepull/run?data={"dsl":0,"dsn":0,"fll":0.6,"fnl":0.75,"ha ":50,"hm":295,"lteh":1532,"nteh":1440.54,"s":true, "tleh":0,"tneh":0}

    i've ditched the port after setting my elasticsearch to run on port 80

    `curl localhost` successfully points towards elasticsearch and returns fine. therefore has to be an issue with CreateHTTPRequest
    https://github.com/ThePianoDentist/t...dentistdotabot Lina bot which pulls small camp when 'laning' (Aim to work on pulling and stacking bots initially)
    https://github.com/ThePianoDentist/dotabots-ml-tools Parsing data from bot games

  4. #4
    if this does get fixed. Can I pre-emptively ask to also be able to specify data for POST request in request body, not just as url arguments.
    I believe the CreateHTTPRequest for custom games already has this.

    Also this may be the most sensible way to remove the max-length issue if you have a large request to send (more than 256 chars)


    (my implementation for using this data I think I've realised cant work with url arguments I can change but it'd be nice for it to just work)
    https://github.com/ThePianoDentist/t...dentistdotabot Lina bot which pulls small camp when 'laning' (Aim to work on pulling and stacking bots initially)
    https://github.com/ThePianoDentist/dotabots-ml-tools Parsing data from bot games

  5. #5
    Valve Developer
    Join Date
    Sep 2011
    Posts
    1,665
    Can you post your entire call to the code?

    I'll also up the maximum length of the string to 8k.

  6. #6
    Basic Member
    Join Date
    Dec 2016
    Posts
    29
    Not my thread, but:

    Code:
    print(CreateHTTPRequest(""))
    will print nil all the time, although I have a server running on port 80 (ncat -l 127.0.0.1 80, to be precise).
    It's a somewhat minimalistic example, but from what I read it should still work.

    Edit: Just came to mind: Could there be something wrong with "localhost" on windows systems? I believe I had some minor issues with that in the past. Not sure.
    Last edited by Justus Mea; 03-28-2017 at 06:33 AM.

  7. #7
    Valve Developer
    Join Date
    Sep 2011
    Posts
    1,665
    Ah, I see the issue, dumb oversight on my part.

  8. #8
    Basic Member
    Join Date
    Dec 2016
    Posts
    611
    Quote Originally Posted by ChrisC View Post
    Ah, I see the issue, dumb oversight on my part.
    Has this been fixed? I'm getting a non-nil return now, as in it returns a table with a single key, value:
    Code:
    [VScript] __self	userdata: 0x00245400
    But doing a Send via:
    Code:
            local req = CreateHTTPRequest("")
            if req then
                req:Send(function(res)
                    print(res)
                end)
            end
    Doesn't seem to hit the cherrypy server I have running on localhost:80 that I can browse to no problem

    also apparently there is an issue with Send() - traceback:
    Code:
    [VScript] Script Runtime Error: attempt to call a table value
    stack traceback:
    So my understanding is that the CreateHTTPResponse object will have the asynchronous Send() function which should take a callback function as an argument...
    Last edited by nostrademous; 04-05-2017 at 09:43 PM.

  9. #9
    CreateHTTPRequestScriptVM (mind that they just renamed it) takes two parameters, the method ("POST", "GET") and the Url:

    Code:
    request = CreateHTTPRequestScriptVM( "GET", myUrl)
    request:Send( function( result ) 
                  -- do whatever
    end )

  10. #10
    Basic Member
    Join Date
    Dec 2016
    Posts
    611
    Quote Originally Posted by Lightbringer View Post
    CreateHTTPRequestScriptVM (mind that they just renamed it) takes two parameters, the method ("POST", "GET") and the Url:

    Code:
    request = CreateHTTPRequestScriptVM( "GET", myUrl)
    request:Send( function( result ) 
                  -- do whatever
    end )
    I believe that's for modding only, not available via the bot-scripting API. The Bot Scripting API is CreateHTTPRequest( sParam ) that only takes 1 parameter as @ChrisC wanted to force only allowing a "POST" and only to "http://localhost". Perhaps he added the second parameter as "http://localhost/" with the extra "/" at end prevent us from specifying port of our choosing, not sure.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •