Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
That is not what the documentation says: If the object is a ByteArray object, the binary data of the ByteArray object is used as POST data. For GET, data of ByteArray type is not supported. Also, data of ByteArray type is not supported for FileReference.upload() and FileReference.download(). from http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequest.html#data I was doing a POST with a ByteArray as the data. Again, this works correctly under Windows and OS X, so I'm pretty sure this is a Player bug under Linux. -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com -Original Message- From: jitendra jain [EMAIL PROTECTED] Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte Date: Tue, 30 Sep 2008 09:13:59 +0530 (IST) All the request data that is send is String. Thanks, with Regards, Jitendra Jain - Original Message From: Troy Gilbert [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Tuesday, 30 September, 2008 9:03:14 AM Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte We're also working around this by Base64-encoding, but this is clearly less than ideal. It definitely seems like a Flash Player bug. We ran into this when doing AlivePDF REMOTE saves (i.e., bouncing the file off the server). Do you know when you ran into this, Troy? I tested our particular problem on Windows and on OS X last week, and neither had the issue. // this byte array probably needs to be bigger to actually end up // with a zero-byte in the compressed data var bytes:ByteArray = new ByteArray(); bytes.writeUTFBytes (This is just some filler text.); bytes.compress( ); // URLVariables automatically encodes its dynamic properties // using a www-form-url- encode format, i.e. %12%34%56%78% 90 var variables:URLVariab les = new URLVariables( ); variables.username = troy; variables.action = save; variables.data = bytes; // when the request is made, 'variables' is converted to a string // the nulls in the ByteArray are not escaped, so they truncate the data var request:URLRequest = new URLRequest(http://mywebserver/ myscript. php); request.method = URLRequestMethod. POST; request.data = variables; // Troy. Add more friends to your messenger and enjoy! Invite them now.
Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
Ah, interesting. This seems related, but different. I was just setting URLRequest.data to a ByteArray directly. In your case, if I understand application/x-www-form-urlencoded correctly, then zero bytes should just be replaced with %00. Have you filed a bug? I'd like to add that to my Adobe JIRA watch list if so. -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com -Original Message- From: Troy Gilbert [EMAIL PROTECTED] Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte Date: Mon, 29 Sep 2008 22:33:14 -0500 We're also working around this by Base64-encoding, but this is clearly less than ideal. It definitely seems like a Flash Player bug. We ran into this when doing AlivePDF REMOTE saves (i.e., bouncing the file off the server). Do you know when you ran into this, Troy? I tested our particular problem on Windows and on OS X last week, and neither had the issue. // this byte array probably needs to be bigger to actually end up // with a zero-byte in the compressed data var bytes:ByteArray = new ByteArray(); bytes.writeUTFBytes(This is just some filler text.); bytes.compress(); // URLVariables automatically encodes its dynamic properties // using a www-form-url-encode format, i.e. %12%34%56%78%90 var variables:URLVariables = new URLVariables(); variables.username = troy; variables.action = save; variables.data = bytes; // when the request is made, 'variables' is converted to a string // the nulls in the ByteArray are not escaped, so they truncate the data var request:URLRequest = new URLRequest(http://mywebserver/myscript.php;); request.method = URLRequestMethod.POST; request.data = variables; // Troy.
Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
Ah, interesting. This seems related, but different. I was just setting URLRequest.data to a ByteArray directly. In your case, if I understand application/x-www-form-urlencoded correctly, then zero bytes should just be replaced with %00. Have you filed a bug? I'd like to add that to my Adobe JIRA watch list if so. It does work correctly if you set URLRequest.data to a ByteArray, but in my example I was setting URLVariables.data (which could be called anything, it's just a named property) to a ByteArray, and URLVariables (apparently) calls toString on each property's value *before* URL-encoding them, which is the problem. So, not necessarily a bug, just an undocumented feature of the implementation. Since URLVariables does the encoding, I expected/assumed (since it wasn't explicitly documented) it would it encode the ByteArray as bytes, %00 and all. Troy.
Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
I'm not sure I agree--if it's a feature of the implementation that prevents valid use of the API, that sounds like a bug ;). As far as I can tell, a null byte should be encoded to %00 in the application/x-form-urlencoded scheme and is a valid character. If calling toString() on a ByteArray truncates it, then the implementation shouldn't be doing that. String does seem to handle null bytes correctly in other cases (try trace(String.fromCharCode(1,0,2).length) ), so there should be no problem here. Also: It does work correctly if you set URLRequest.data to a ByteArray Not in Linux Flash Player--that was my original point. Thanks for the feedback, though--it's always interesting to dive into this low-level stuff. -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com -Original Message- From: Troy Gilbert [EMAIL PROTECTED] Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte Date: Tue, 30 Sep 2008 11:57:09 -0500 Ah, interesting. This seems related, but different. I was just setting URLRequest.data to a ByteArray directly. In your case, if I understand application/x-www-form-urlencoded correctly, then zero bytes should just be replaced with %00. Have you filed a bug? I'd like to add that to my Adobe JIRA watch list if so. It does work correctly if you set URLRequest.data to a ByteArray, but in my example I was setting URLVariables.data (which could be called anything, it's just a named property) to a ByteArray, and URLVariables (apparently) calls toString on each property's value *before* URL-encoding them, which is the problem. So, not necessarily a bug, just an undocumented feature of the implementation. Since URLVariables does the encoding, I expected/assumed (since it wasn't explicitly documented) it would it encode the ByteArray as bytes, %00 and all. Troy.
Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
Please check the following and it will clear what i need to say.. The way in which the data is used depends on the type of object used: * If the object is a ByteArray object, the binary data of the ByteArray object is used as POST data. For GET, data of ByteArray type is not supported. Also, data of ByteArray type is not supported for FileReference.upload() and FileReference.download(). * If the object is a URLVariables object and the method is POST, the variables are encoded using x-www-form-urlencoded format and the resulting string is used as POST data. An exception is a call to FileReference.upload(), in which the variables are sent as separate fields in a multipart/form-data post. * If the object is a URLVariables object and the method is GET, the URLVariables object defines variables to be sent with the URLRequest object. * Otherwise, the object is converted to a string, and the string is used as the POST or GET data. Thanks, with Regards, Jitendra Jain - Original Message From: Maciek Sakrejda [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Tuesday, 30 September, 2008 9:13:51 PM Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte That is not what the documentation says: If the object is a ByteArray object, the binary data of the ByteArray object is used as POST data. For GET, data of ByteArray type is not supported. Also, data of ByteArray type is not supported for FileReference. upload() and FileReference. download( ). from http://livedocs. adobe.com/ flex/3/langref/ flash/net/ URLRequest. html#data I was doing a POST with a ByteArray as the data. Again, this works correctly under Windows and OS X, so I'm pretty sure this is a Player bug under Linux. -- Maciek Sakrejda Truviso, Inc. http://www.truviso. com -Original Message- From: jitendra jain jitendra_jain_ [EMAIL PROTECTED] com Reply-To: [EMAIL PROTECTED] ups.com To: [EMAIL PROTECTED] ups.com Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte Date: Tue, 30 Sep 2008 09:13:59 +0530 (IST) All the request data that is send is String. Thanks, with Regards, Jitendra Jain - Original Message From: Troy Gilbert troy.gilbert@ gmail.com To: [EMAIL PROTECTED] ups.com Sent: Tuesday, 30 September, 2008 9:03:14 AM Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte We're also working around this by Base64-encoding, but this is clearly less than ideal. It definitely seems like a Flash Player bug. We ran into this when doing AlivePDF REMOTE saves (i.e., bouncing the file off the server). Do you know when you ran into this, Troy? I tested our particular problem on Windows and on OS X last week, and neither had the issue. // this byte array probably needs to be bigger to actually end up // with a zero-byte in the compressed data var bytes:ByteArray = new ByteArray(); bytes.writeUTFBytes (This is just some filler text.); bytes.compress( ); // URLVariables automatically encodes its dynamic properties // using a www-form-url- encode format, i.e. %12%34%56%78% 90 var variables:URLVariab les = new URLVariables( ); variables.username = troy; variables.action = save; variables.data = bytes; // when the request is made, 'variables' is converted to a string // the nulls in the ByteArray are not escaped, so they truncate the data var request:URLRequest = new URLRequest(http://mywebserver/ myscript. php); request.method = URLRequestMethod. POST; request.data = variables; // Troy. _ _ _ _ _ _ Add more friends to your messenger and enjoy! Invite them now. Be the first one to try the new Messenger 9 Beta! Go to http://in.messenger.yahoo.com/win/
Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
Hi all, I've create the following ticket: http://bugs.adobe.com/jira/browse/FP-708 It seems to be a core Flash Player issue, and not anything Flex-related, but if you care about Linux Flash Player, I'm not above begging for votes. -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com -Original Message- From: Maciek Sakrejda [EMAIL PROTECTED] Reply-To: flexcoders@yahoogroups.com To: flexcoders flexcoders@yahoogroups.com Subject: [flexcoders] URLRequest, ByteArray, and the 0 byte Date: Thu, 25 Sep 2008 12:36:10 -0700 I've run into an interesting problem with URLRequest, navigateToURL, and ByteArray when sending a zero byte: var bytes:ByteArray = new ByteArray(); bytes.writeByte(1); bytes.writeByte(1); bytes.writeByte(1); bytes.writeByte(1); requestHeader = new URLRequestHeader(Content-type, application/octet-stream); // Where ../../test is just a valid dummy url--it doesn't matter what it // actually does with the request request:URLRequest = new URLRequest(../../test); request.requestHeaders.push(header); request.method = URLRequestMethod.POST; request.data = bytes; navigateToURL(request, _blank); I write four bytes above, because that seems to be a minimum for URLRequest (if I write just one byte, the Content-Length header is set to 4 anyway), but that's a separate issue. If I change one of those bytes.writeByte(1) to bytes.writeByte(0) The byte array seems to be truncated to the location of that byte. In general, any ByteArray sent as a data property payload of a URLRequest seems to be truncated to the location of the first zero byte. I've confirmed this by checking the Content-Length header of the POST request (in fact, if the *first* byte is zero, the request seems to be turned into a GET--which is even weirder). I'm using FP 9.0.124.0 on Linux. I just tested on a colleague's machine, and this seems to work fine in FP on Vista. Is this a known issue? Is there any way around this? -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com
Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
The byte array seems to be truncated to the location of that byte. In general, any ByteArray sent as a data property payload of a URLRequest seems to be truncated to the location of the first zero byte. I've confirmed this by checking the Content-Length header of the POST request (in fact, if the *first* byte is zero, the request seems to be turned into a GET--which is even weirder). Just ran into a similar issue under OSX/Windows. If I tried to stick a ByteArray into a URLVariables, no matter what combination of operations I'd make, somewhere along the line it got converted to a String and thus truncated at the first zero byte (because I assume Flash uses null-terminated strings internally). To fix it, I ended up encoding the data in Base64 before sticking it into the URLVariables, which I think was actually a win over the URL-encoding (e.g. %03%38%99...) anyway. In regards to your POST/GET issue, Flash Player appears to convert empty POSTs to GETs, which would explain why 0 has the first byte (thus a zero-length data) would turn your POST into a GET. Troy.
Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
We're also working around this by Base64-encoding, but this is clearly less than ideal. It definitely seems like a Flash Player bug. We ran into this when doing AlivePDF REMOTE saves (i.e., bouncing the file off the server). Do you know when you ran into this, Troy? I tested our particular problem on Windows and on OS X last week, and neither had the issue. -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com -Original Message- From: Troy Gilbert [EMAIL PROTECTED] Reply-To: flexcoders@yahoogroups.com To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte Date: Mon, 29 Sep 2008 16:07:45 -0500 The byte array seems to be truncated to the location of that byte. In general, any ByteArray sent as a data property payload of a URLRequest seems to be truncated to the location of the first zero byte. I've confirmed this by checking the Content-Length header of the POST request (in fact, if the *first* byte is zero, the request seems to be turned into a GET--which is even weirder). Just ran into a similar issue under OSX/Windows. If I tried to stick a ByteArray into a URLVariables, no matter what combination of operations I'd make, somewhere along the line it got converted to a String and thus truncated at the first zero byte (because I assume Flash uses null-terminated strings internally). To fix it, I ended up encoding the data in Base64 before sticking it into the URLVariables, which I think was actually a win over the URL-encoding (e.g. %03%38%99...) anyway. In regards to your POST/GET issue, Flash Player appears to convert empty POSTs to GETs, which would explain why 0 has the first byte (thus a zero-length data) would turn your POST into a GET. Troy.
Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
We're also working around this by Base64-encoding, but this is clearly less than ideal. It definitely seems like a Flash Player bug. We ran into this when doing AlivePDF REMOTE saves (i.e., bouncing the file off the server). Do you know when you ran into this, Troy? I tested our particular problem on Windows and on OS X last week, and neither had the issue. // this byte array probably needs to be bigger to actually end up // with a zero-byte in the compressed data var bytes:ByteArray = new ByteArray(); bytes.writeUTFBytes(This is just some filler text.); bytes.compress(); // URLVariables automatically encodes its dynamic properties // using a www-form-url-encode format, i.e. %12%34%56%78%90 var variables:URLVariables = new URLVariables(); variables.username = troy; variables.action = save; variables.data = bytes; // when the request is made, 'variables' is converted to a string // the nulls in the ByteArray are not escaped, so they truncate the data var request:URLRequest = new URLRequest(http://mywebserver/myscript.php;); request.method = URLRequestMethod.POST; request.data = variables; // Troy.
Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
All the request data that is send is String. Thanks, with Regards, Jitendra Jain - Original Message From: Troy Gilbert [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Tuesday, 30 September, 2008 9:03:14 AM Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte We're also working around this by Base64-encoding, but this is clearly less than ideal. It definitely seems like a Flash Player bug. We ran into this when doing AlivePDF REMOTE saves (i.e., bouncing the file off the server). Do you know when you ran into this, Troy? I tested our particular problem on Windows and on OS X last week, and neither had the issue. // this byte array probably needs to be bigger to actually end up // with a zero-byte in the compressed data var bytes:ByteArray = new ByteArray(); bytes.writeUTFBytes (This is just some filler text.); bytes.compress( ); // URLVariables automatically encodes its dynamic properties // using a www-form-url- encode format, i.e. %12%34%56%78% 90 var variables:URLVariab les = new URLVariables( ); variables.username = troy; variables.action = save; variables.data = bytes; // when the request is made, 'variables' is converted to a string // the nulls in the ByteArray are not escaped, so they truncate the data var request:URLRequest = new URLRequest(http://mywebserver/ myscript. php); request.method = URLRequestMethod. POST; request.data = variables; // Troy. Be the first one to try the new Messenger 9 Beta! Go to http://in.messenger.yahoo..com/win/
Re: [flexcoders] URLRequest, ByteArray, and the 0 byte
If you are using Java as server side , then this string need to be converted into bytes and then send it to the ServletInputStream. Might this will be help. Thanks, with Regards, Jitendra Jain - Original Message From: jitendra jain [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Tuesday, 30 September, 2008 9:13:59 AM Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte All the request data that is send is String. Thanks, with Regards, Jitendra Jain - Original Message From: Troy Gilbert troy.gilbert@ gmail.com To: [EMAIL PROTECTED] ups.com Sent: Tuesday, 30 September, 2008 9:03:14 AM Subject: Re: [flexcoders] URLRequest, ByteArray, and the 0 byte We're also working around this by Base64-encoding, but this is clearly less than ideal. It definitely seems like a Flash Player bug. We ran into this when doing AlivePDF REMOTE saves (i.e., bouncing the file off the server). Do you know when you ran into this, Troy? I tested our particular problem on Windows and on OS X last week, and neither had the issue. // this byte array probably needs to be bigger to actually end up // with a zero-byte in the compressed data var bytes:ByteArray = new ByteArray(); bytes.writeUTFBytes (This is just some filler text.); bytes.compress( ); // URLVariables automatically encodes its dynamic properties // using a www-form-url- encode format, i.e. %12%34%56%78% 90 var variables:URLVariab les = new URLVariables( ); variables.username = troy; variables.action = save; variables.data = bytes; // when the request is made, 'variables' is converted to a string // the nulls in the ByteArray are not escaped, so they truncate the data var request:URLRequest = new URLRequest(http://mywebserver/ myscript. php); request.method = URLRequestMethod. POST; request.data = variables; // Troy. Add more friends to your messenger and enjoy! Invite them now. From Chandigarh to Chennai - find friends all over India. Go to http://in.promos.yahoo.com/groups/citygroups/
[flexcoders] URLRequest, ByteArray, and the 0 byte
I've run into an interesting problem with URLRequest, navigateToURL, and ByteArray when sending a zero byte: var bytes:ByteArray = new ByteArray(); bytes.writeByte(1); bytes.writeByte(1); bytes.writeByte(1); bytes.writeByte(1); requestHeader = new URLRequestHeader(Content-type, application/octet-stream); // Where ../../test is just a valid dummy url--it doesn't matter what it // actually does with the request request:URLRequest = new URLRequest(../../test); request.requestHeaders.push(header); request.method = URLRequestMethod.POST; request.data = bytes; navigateToURL(request, _blank); I write four bytes above, because that seems to be a minimum for URLRequest (if I write just one byte, the Content-Length header is set to 4 anyway), but that's a separate issue. If I change one of those bytes.writeByte(1) to bytes.writeByte(0) The byte array seems to be truncated to the location of that byte. In general, any ByteArray sent as a data property payload of a URLRequest seems to be truncated to the location of the first zero byte. I've confirmed this by checking the Content-Length header of the POST request (in fact, if the *first* byte is zero, the request seems to be turned into a GET--which is even weirder). I'm using FP 9.0.124.0 on Linux. I just tested on a colleague's machine, and this seems to work fine in FP on Vista. Is this a known issue? Is there any way around this? -- Maciek Sakrejda Truviso, Inc. http://www.truviso.com