THREAD: [C++] How to get char from website with SPRX ?
  1. 06-13-2017, 05:15 PM
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    403
    Posts
    5,883
    Reputation
    Mar 2015
    NextGenUpdate
    Hi NextGenUpdate,

    Actually i work on my sprx for get char from website, for example You must login or register to view this content.
    I have maked one webFunctions.h little edited, You must login or register to view this content.
    And after i use char* one = SocketRequest("pastebin.com", "raw/xNCb6hrS"); but it's not work and char display HTTP 1.1 / 200 OK..... or the game freez (depend website)
    And not char "Hello" in website, so i hope few people can help for this Smile

    Thank in advance,
    Cordially, Smoulougde.
    Last edited by Smoulougde ; 06-13-2017 at 05:19 PM.

  2. The Following User Thanked Smoulougde For This Useful Post:


  3. 06-13-2017, 09:38 PM
    Tustin's Avatar
    Tustin
    Balls of Steel
    Tustin's Avatar
    Tustin
    Balls of Steel
    5,462
    Posts
    310,646
    Reputation
    May 2008
    NextGenUpdate
    Originally Posted by Smoulougde View Post
    Hi NextGenUpdate,

    Actually i work on my sprx for get char from website, for example You must login or register to view this content.
    I have maked one webFunctions.h little edited, You must login or register to view this content.
    And after i use char* one = SocketRequest("pastebin.com", "raw/xNCb6hrS"); but it's not work and char display HTTP 1.1 / 200 OK..... or the game freez (depend website)
    And not char "Hello" in website, so i hope few people can help for this Smile

    Thank in advance,
    Cordially, Smoulougde.


    That response you're going to get from the sockets will include both the HTTP header and the response. HTTP headers and bodies are delimited by

    , so what you'll want to do is use something like strstr to split the response and then you can do some pointer arithmetic to read the body. Here's the function I made to do that:

    //Parses the response body from a full response buffer
    char* GetResponseBody(char* responseBuffer) {
    char* output = strstr(responseBuffer, "

    ");
    if (output == NULL) {
    return NULL;
    }
    output += 4;
    return output;
    }

    Make sure you check for NULL after you call this function just in case it failed to split

    (might happen if the socket failed or something).
  4. The Following User Thanked Tustin For This Useful Post:


  5. 06-14-2017, 12:45 AM
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    403
    Posts
    5,883
    Reputation
    Mar 2015
    NextGenUpdate
    Originally Posted by Tustin View Post
    That response you're going to get from the sockets will include both the HTTP header and the response. HTTP headers and bodies are delimited by

    , so what you'll want to do is use something like strstr to split the response and then you can do some pointer arithmetic to read the body. Here's the function I made to do that:

    //Parses the response body from a full response buffer
    char* GetResponseBody(char* responseBuffer) {
    char* output = strstr(responseBuffer, "

    ");
    if (output == NULL) {
    return NULL;
    }
    output += 4;
    return output;
    }

    Make sure you check for NULL after you call this function just in case it failed to split

    (might happen if the socket failed or something).


    Ok i understand, thank you for your answer. I would test this tomorrow and I would keep you informed if it works or not Smile
  6. 06-14-2017, 05:53 PM
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    403
    Posts
    5,883
    Reputation
    Mar 2015
    NextGenUpdate
    Originally Posted by Tustin View Post
    That response you're going to get from the sockets will include both the HTTP header and the response. HTTP headers and bodies are delimited by

    , so what you'll want to do is use something like strstr to split the response and then you can do some pointer arithmetic to read the body. Here's the function I made to do that:

    //Parses the response body from a full response buffer
    char* GetResponseBody(char* responseBuffer) {
    char* output = strstr(responseBuffer, "

    ");
    if (output == NULL) {
    return NULL;
    }
    output += 4;
    return output;
    }

    Make sure you check for NULL after you call this function just in case it failed to split

    (might happen if the socket failed or something).


    I have try your coding with different ways.

    webFunctions.h is You must login or register to view this content.

    And in my function i use this
    if (value)
    {
    char* one;
    if (!requestinfos)
    {
    one = SocketRequest("pastebin.com", "raw/xNCb6hrS");
    requestinfos = true; //To remove or not, it depends. This is to load the tank once if included. Otherwise it will load it all the time
    }
    draw_text(one, 0, 0.4, 0.5, 0.5, 255, 255, 255, 255, center);
    }


    But each time the freez game if i activate the option, you would know why ?
  7. 06-26-2017, 06:40 PM
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    403
    Posts
    5,883
    Reputation
    Mar 2015
    NextGenUpdate
    Anyone ?
  8. 07-23-2017, 07:13 PM
    14
    Posts
    90
    Reputation
    Aug 2014
    NextGenUpdate
    Same Problem...
  9. 08-20-2017, 05:20 PM
    4
    Posts
    10
    Reputation
    Feb 2015
    NextGenUpdate
    Hey bro I'm with the same problem I try to do this in my menu, appears http /1.0 .... or freezes the game, does anyone have a solution for this? I'll be very grateful Smile
  10. 02-07-2018, 10:44 AM
    PassiveBypass's Avatar
    PassiveBypass
    Do a barrel roll!
    PassiveBypass's Avatar
    PassiveBypass
    Do a barrel roll!
    104
    Posts
    599
    Reputation
    Oct 2015
    NextGenUpdate
    frrst freeze occurs here:

    SocketAddress.sin_addr.s_addr = *((unsigned long*)Host->h_addr);
  11. The Following User Thanked PassiveBypass For This Useful Post:


  12. 02-08-2018, 05:25 AM
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    Smoulougde's Avatar
    Smoulougde
    S.P.E.C.I.A.L
    403
    Posts
    5,883
    Reputation
    Mar 2015
    NextGenUpdate
    Originally Posted by PassiveBypass View Post
    frrst freeze occurs here:

    SocketAddress.sin_addr.s_addr = *((unsigned long*)Host->h_addr);


    What do you recommend so?
  13. 02-08-2018, 12:42 PM
    PassiveBypass's Avatar
    PassiveBypass
    Do a barrel roll!
    PassiveBypass's Avatar
    PassiveBypass
    Do a barrel roll!
    104
    Posts
    599
    Reputation
    Oct 2015
    NextGenUpdate
    tbh I'm stuck here like everyone else lol, I am guessing there are some issues using socketaddress stuff. May not be fully supported or something but I'm not sure.