PDA

View Full Version : Problem with ISOCKET_Write


arunbangari
04-02-2002, 05:56 AM
Hi,
Iam working on a app which makes use of socket to get the data from the server. When i send the request, if the request string has any spaces in between, iam not able to retrieve the data. For eg. when i try this
ISOCKET_Write(m_piSock, (byte*)Request, (uint16)STRLEN(Request)); where the request string is,
http://10.21.57.40:80/servlet/TestData?cat=Theme Songs&category_id=30. If I remove the white space between Theme Songs, it works fine. Has any one faced this problem? Is there any solution ?

Thanks in Advance.
Arun Bangari

raja
04-02-2002, 06:05 PM
hi
The white spaces create problem bcoz the query strings cannot contain whitespaces as is, in the parameter values. What u can do is replace space character with + and the + will be interpreted as space by your server.

As in ur example instead of giving "Theme Songs" try it as "Theme+Songs". It will be interpreted as Space.

This will work

raja

arunbangari
04-02-2002, 08:38 PM
Hi raja,
Thanks for your suggestion. I agree on this. What i have observed is when we type the same url in the browser, the white space will be replaced by %20. Is there any API call where we can do this conversion?Is there any way other than how you have described?

Thanks in advance.
Arun Bangari


Originally posted by raja
hi
The white spaces create problem bcoz the query strings cannot contain whitespaces as is, in the parameter values. What u can do is replace space character with + and the + will be interpreted as space by your server.

As in ur example instead of giving "Theme Songs" try it as "Theme+Songs". It will be interpreted as Space.

This will work

raja

raja
04-03-2002, 12:15 AM
hi
Ya, u r correct. But as far as i searched in the BREW API's there r no Function calls for converting or replacing the white spaces with +. Instead u will have to write ur own ( have done it here and it works fine ).


regards
raja

arunbangari
04-03-2002, 06:01 AM
Hi,
Yes, even i had searched through the SDK and did not find any API. It need not be only '+' but can be%20 also. Which all the browser does when they encounter white space. I was looking for an API call which will encode this string. I Found IWEBUTIL_UrlEncode api call in IWebUtil interface. Iam not sure what this function will do. Thanks for your suggestion as iam able to get it back to work by replacing space with '+'

Thanks
Arun Bangri

Originally posted by raja
hi
Ya, u r correct. But as far as i searched in the BREW API's there r no Function calls for converting or replacing the white spaces with +. Instead u will have to write ur own ( have done it here and it works fine ).


regards
raja

raajeev_kuppa
04-09-2002, 10:03 AM
Arun,

Spaces are interpreted as "%" so when you send "Theme songs" it is intrepreted as "Theme%songs".

Raajeev

Jason
04-09-2002, 12:31 PM
Hi,

URLEncode is probably the best idea for your applicaion, in case there are other reserved characters that must be escaped that may show up in your URLs that you work with. This way you won't have to rewrite code, or constantly add to code as you come across different characters that would expect to be encoded.

jason.