Thread: [Simpleweb-Support] Wrong Parameter value
Brought to you by:
niallg
From: Baptiste D. <bap...@gm...> - 2007-01-28 20:49:14
|
Hi again... Actually, I think my problems comes from the fact that the parameters are stored as String, and not as byte[] or something, which means it must have been translated using a given charset... But maybe this charset just drop characters that it does not know, as they are written in %xy notation... Is it possible? And if so, how could I access the true value? Or maybe should I modify the request class? Thank you for any answer... Bat |
From: Niall G. <gal...@ya...> - 2007-01-29 23:26:23
|
Hi Baptiste, Just use base64, or some other way to escape the parameter. You should not really send binary in parameter values. Niall --- Baptiste Dubuis <bap...@gm...> wrote: > Hi again... > > Actually, I think my problems comes from the fact > that the parameters are > stored as String, and not as byte[] or something, > which means it must have > been translated using a given charset... But maybe > this charset just drop > characters that it does not know, as they are > written in %xy notation... > > Is it possible? And if so, how could I access the > true value? Or maybe > should I modify the request class? > > Thank you for any answer... > > Bat > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get > the chance to share your > opinions on IT & business topics through brief > surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV> _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher ____________________________________________________________________________________ Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html |
From: Bat <bap...@gm...> - 2007-01-30 00:17:03
|
Hi Nial Thanks for your answer but I'm not sure to get what you mean... Actually I'm writting Bittorrent softwares (client, tracker, publisher, ...) and I use Simple as the web server that handle the request for uploading torrents and providing peers information. The protocol requires some data to be sent to the tracker as parameters, for example file or peer id. These values are 20 random bytes and could therefore be any value between 00 and FF, and could possibly not represent any real character. The point is I don't have to display their value as a string, but just get the value (in hex for example...). My problem is, Simple does something that I don't get, because sometimes (but rarely), it works and the value I get is correct, but in most cases, the value is wrong and there are missing byte(s). In short, the String (or byte[] I would prefer) should ALWAYS be of length 20, but this is not the case... So I don't understand your answer about base64, since the String I get with the method getParameter() is of the wrong length and could therefore not serve... By the way, if I'm missing something, I would really appreciate if you could explain me a bit farther... Thank you... Baptiste |
From: Niall G. <gal...@ya...> - 2007-01-30 20:40:59
|
Hi Bat, Well what is happening here is that the decoder for URL's assumes UTF-8. So it will decode in UTF-8 until it sees an illegal char (only legal encodings are ISO-8859-1 and UTF-8 characters). In the case that you do not have control then you need to do the following: String url = Request.getURI(); This contains an unmodified URI string, from here u need to do the decoding yourself, perhaps using the java URLDecoder with an acceptible charset setting. Niall --- Bat <bap...@gm...> wrote: > Hi Nial > > Thanks for your answer but I'm not sure to get what > you mean... > > Actually I'm writting Bittorrent softwares (client, > tracker, publisher, > ...) and I use Simple as the web server that handle > the request for > uploading torrents and providing peers information. > > The protocol requires some data to be sent to the > tracker as parameters, > for example file or peer id. These values are 20 > random bytes and could > therefore be any value between 00 and FF, and could > possibly not > represent any real character. The point is I don't > have to display their > value as a string, but just get the value (in hex > for example...). > > My problem is, Simple does something that I don't > get, because sometimes > (but rarely), it works and the value I get is > correct, but in most > cases, the value is wrong and there are missing > byte(s). In short, the > String (or byte[] I would prefer) should ALWAYS be > of length 20, but > this is not the case... > > So I don't understand your answer about base64, > since the String I get > with the method getParameter() is of the wrong > length and could > therefore not serve... > > By the way, if I'm missing something, I would really > appreciate if you > could explain me a bit farther... > > Thank you... > Baptiste > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get > the chance to share your > opinions on IT & business topics through brief > surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher ____________________________________________________________________________________ Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html |
From: Bat <bap...@gm...> - 2007-01-31 09:49:01
|
Hi Niall Thanks for your help, it now works perfectly... See you Baptiste |