SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/11/2017, 08:12 PM   #1
linuxthefish
High-roller
 
linuxthefish's Avatar
 
Join Date: Dec 2010
Location: Al-Dunya
Posts: 2,858
Reputation: 690
Thumbs down HTTP function broken? Can't send long strings!

Hi,

I'm trying to send a long string using the HTTP function, and it ends up sending nothing at all.

My code:

pawn Code:
new result[1024];
format(result, 1024, "website.com/linuxthefish.php?string=%s", "878248638726478362877bewnh fdhejiwdheiudwuiheuhduihewudheuiwhduiewhduiehwiudheuwh");
HTTP(2, HTTP_GET, result, "", "MyHttpResponse");

What I get in the access log on the webserver is "[13/Nov/2017:19:37:24 +0000] "" 400 349 "-" "-""

With this different code but with a shorter string, it works.

pawn Code:
new result[128];
format(result, 128, "website.com/linuxthefish.php?data=%s", "8.8.8.8");
HTTP(1, HTTP_GET, result, "", "MyHttpResponse");

And I get this in the access logs.

"[13/Nov/2017:18:17:04 +0000] "GET /linuxthefish.php?data=8.8.8.8 HTTP/1.0" 200 0 "http://sa-mp.com" "SAMP/0.3""
__________________
linuxthefish is offline   Reply With Quote
Old 13/11/2017, 08:14 PM   #2
linuxthefish
High-roller
 
linuxthefish's Avatar
 
Join Date: Dec 2010
Location: Al-Dunya
Posts: 2,858
Reputation: 690
Default Re: HTTP function broken? Can't send long strings!

Alternately I could extra the IP 8.8.8.8 from the string "fishtest - Max Speed: 45 MPH, Vehicle Health: 0.00, IP: 8.8.8.8, Ping: 394 ms", but sscanf isn't having any of it
__________________
linuxthefish is offline   Reply With Quote
Old 13/11/2017, 08:33 PM   #3
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,642
Reputation: 541
Default Re: HTTP function broken? Can't send long strings!

Did you try replacing the space with "%20"? Note: In format you need to use 2 percent signs to get one into the actual string. Some webservers are unable to handle it.

Ignore if you tried other long strings without spaces.

Might also be a limitation of length.
NaS is offline   Reply With Quote
Old 13/11/2017, 08:58 PM   #4
linuxthefish
High-roller
 
linuxthefish's Avatar
 
Join Date: Dec 2010
Location: Al-Dunya
Posts: 2,858
Reputation: 690
Default Re: HTTP function broken? Can't send long strings!

Quote:
Originally Posted by NaS View Post
Did you try replacing the space with "%20"? Note: In format you need to use 2 percent signs to get one into the actual string. Some webservers are unable to handle it.

Ignore if you tried other long strings without spaces.

Might also be a limitation of length.
The problem is then I could have to break down the string in sscanf or similar, but the string I'm trying to use I think is too long for the include version. Is there a way to explode a string like in PHP?

$pieces = explode(" ", "Max Speed: 45 MPH, Vehicle Health: 0.00, IP: 8.8.8.8, Ping: 394 ms");
echo $pieces[8];

Code:
fishtest - Max Speed: 45 MPH, Vehicle Health: 0.00, IP: 8.8.8.8, Ping: 394 ms
__________________
linuxthefish is offline   Reply With Quote
Old 13/11/2017, 09:02 PM   #5
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,642
Reputation: 541
Default Re: HTTP function broken? Can't send long strings!

Hmm. Why do you send "Max Speed" etc with it? Why not eg.

Code:
45,0.0,8.8.8.8,394
You can use spaces too, if they work! If you use spaces just for sscanf, you can put "p<,>" in front of the format specifiers to set the delimiter to be a comma.

Or did I get something wrong?
NaS is offline   Reply With Quote
Old 13/11/2017, 09:31 PM   #6
linuxthefish
High-roller
 
linuxthefish's Avatar
 
Join Date: Dec 2010
Location: Al-Dunya
Posts: 2,858
Reputation: 690
Default Re: HTTP function broken? Can't send long strings!

Quote:
Originally Posted by NaS View Post
Hmm. Why do you send "Max Speed" etc with it? Why not eg.

Code:
45,0.0,8.8.8.8,394
You can use spaces too, if they work! If you use spaces just for sscanf, you can put "p<,>" in front of the format specifiers to set the delimiter to be a comma.

Or did I get something wrong?
I'm phrasing the output of something else (or trying to), but then changed my mind and tried to send the whole string to a PHP script. I can't control what parts of the string I receive or modify it before it's sent, apart from after having received it.
__________________
linuxthefish is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I send very long messages? danielpalade Scripting Help 6 01/03/2017 06:01 PM
use HTTP to send variables to php. EviLpRo Scripting Help 4 24/04/2012 10:21 PM
Send Long Message jameskmonger Scripting Help 12 28/11/2011 08:16 PM
HTTP secondary send maij Help Archive 2 16/04/2011 12:03 AM
Using HTTP to send emails Jochemd Help Archive 3 19/02/2011 12:28 PM


All times are GMT. The time now is 10:50 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.