Post: [C++] How to get char from website with SPRX ?
06-13-2017, 05:15 PM #1
Smoulougde
S.P.E.C.I.A.L
(adsbygoogle = window.adsbygoogle || []).push({});
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.

The following user thanked Smoulougde for this useful post:

Krrish Lobbyman
06-13-2017, 09:38 PM #2
Tustin
Balls of Steel
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).

The following user thanked Tustin for this useful post:

Smoulougde
06-14-2017, 12:45 AM #3
Smoulougde
S.P.E.C.I.A.L
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
06-14-2017, 05:53 PM #4
Smoulougde
S.P.E.C.I.A.L
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 ?
06-26-2017, 06:40 PM #5
Smoulougde
S.P.E.C.I.A.L
Anyone ?
07-23-2017, 07:13 PM #6
Same Problem...
08-20-2017, 05:20 PM #7
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
02-07-2018, 10:44 AM #8
PassiveBypass
Do a barrel roll!
frrst freeze occurs here:
    
SocketAddress.sin_addr.s_addr = *((unsigned long*)Host->h_addr);

The following user thanked PassiveBypass for this useful post:

Krrish Lobbyman
02-08-2018, 05:25 AM #9
Smoulougde
S.P.E.C.I.A.L
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?
02-08-2018, 12:42 PM #10
PassiveBypass
Do a barrel roll!
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.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo