HTTP post return adding 0 at the end.

For general discussion related FlowStone
Post Reply
User avatar
CoreStylerz
Posts: 327
Joined: Sun Jan 22, 2012 2:19 am
Location: italy
Contact:

HTTP post return adding 0 at the end.

Post by CoreStylerz »

I don't know why, i'm getting wrong values return in flowstone.
The error is flowstone add a 0 at the end of the returned string.

I'm still investigating but the php script (i checked it) doesn't give this 0 at the end while the returned http-post string yes!
Anyone had the same issue?

PS i checked once more.
Flowstone add a 0 at the end of the numeric string WTF.
Need my support for app development, website or custom scripts?
PM me if you are interested.
Experienced Java, J2EE, PHP, Javascript, Angular, Cloud Solutions developer.
Drnkhobo
Posts: 312
Joined: Sun Aug 19, 2012 7:13 pm
Location: ZA

Re: HTTP post return adding 0 at the end.

Post by Drnkhobo »

Hey CS I have had the same problem. No matter what I do FS always adds the 0 at the end of returned string. I simply made a Ruby to remove it. . . havent found any other solution. I think its a problem within the HTTP prim itself... :cry:
User avatar
CoreStylerz
Posts: 327
Joined: Sun Jan 22, 2012 2:19 am
Location: italy
Contact:

Re: HTTP post return adding 0 at the end.

Post by CoreStylerz »

Drnkhobo wrote:Hey CS I have had the same problem. No matter what I do FS always adds the 0 at the end of returned string. I simply made a Ruby to remove it. . . havent found any other solution. I think its a problem within the HTTP prim itself... :cry:

The problem is that sometimes doesn't happen! That it's bad because you can't return correct values from php to be always stable..

Hey support can you give us some info? a fix or maybe a workaround?
If i undestand WHEN it add this 0 will be cool
Need my support for app development, website or custom scripts?
PM me if you are interested.
Experienced Java, J2EE, PHP, Javascript, Angular, Cloud Solutions developer.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: HTTP post return adding 0 at the end.

Post by tulamide »

Text encoding issues? Maybe the server returns something else then ASCII.
Or the char[] gets messed up? (Since "\0" marks the end of a c string)
"There lies the dog buried" (German saying translated literally)
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

HTTP POST example with Client Primitive

Post by Tronic »

Not tested, but should work ...
use this ruby code with Client Primitive.

Code: Select all

# TRONIC - HTTP POST EXAMPLE - use it with Client Primitive 
# see HTTP protocol for more info
header = "POST /your-url-where-post HTTP/1.1\r\n"
header+= "User-Agent: FLOWSTONERS DEVELOPER\r\n"
header+= "From: user@server.mail\r\n" # optional
header+= "Content-Type: application/x-www-form-urlencoded; charset=us-ascii\r\n"
header+= "Content-Length: #{@body.size}\r\n" # set size accordly to lenght of body text
header+= "Accept: text/plain\r\n" # or other Type
header+= "Accept-Charset: us-ascii\r\n"
header+= "Accept-Language: en-us\r\n"
header+= "Connection: Keep-Alive\r\n"
header+= "\r\n" # end header
# body is url encoded
# Example: parameter=value&also=another
@body = "MACHINEID=123456789&EMAIL=user@server.mail"

request = header + @body
request_as_txt = request
request_as_hex = request.unpack('H*')

output 0, request_as_txt # use as txt Type in Client Primitive
output 1, request_as_hex # use as hex Type in Client Primitive
Last edited by Tronic on Mon Oct 13, 2014 7:57 pm, edited 1 time in total.
User avatar
CoreStylerz
Posts: 327
Joined: Sun Jan 22, 2012 2:19 am
Location: italy
Contact:

Re: HTTP post return adding 0 at the end.

Post by CoreStylerz »

Encoding a string to base64 will solve this? (decoding then in flowstone)
Need my support for app development, website or custom scripts?
PM me if you are interested.
Experienced Java, J2EE, PHP, Javascript, Angular, Cloud Solutions developer.
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: HTTP post return adding 0 at the end.

Post by Tronic »

depends on how you structured your php code when you create your data before convert it to EncodedBase64.
User avatar
CoreStylerz
Posts: 327
Joined: Sun Jan 22, 2012 2:19 am
Location: italy
Contact:

Re: HTTP post return adding 0 at the end.

Post by CoreStylerz »

working well encoding data with base64.
Need my support for app development, website or custom scripts?
PM me if you are interested.
Experienced Java, J2EE, PHP, Javascript, Angular, Cloud Solutions developer.
Post Reply