
SolveLLC
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2010
10:55 AM
escaping spaces in URL
searchText = screen.GetText()
print "search text: "; searchText
m.UrlBase = "http://somewebserver.com/web/"
m.Text = "/sample.php?text="
rhttp = NewHttp(m.UrlBase + m.Text + searchText)
rsp = rhttp.Http.GetToString()
I'm posting as a GET to a webserver. searchText is the result of input from the roKeyboardScreen. If I have spaces or reserved characters in searchText, it will print to the debug console, but the http GET silently fails.
My webserver will certainly take something like this http://somewebserver/web/sample.php?text=1111 3333
Is there anything I can do in Brightscript to quote searchText to be passed?
print "search text: "; searchText
m.UrlBase = "http://somewebserver.com/web/"
m.Text = "/sample.php?text="
rhttp = NewHttp(m.UrlBase + m.Text + searchText)
rsp = rhttp.Http.GetToString()
I'm posting as a GET to a webserver. searchText is the result of input from the roKeyboardScreen. If I have spaces or reserved characters in searchText, it will print to the debug console, but the http GET silently fails.
My webserver will certainly take something like this http://somewebserver/web/sample.php?text=1111 3333
Is there anything I can do in Brightscript to quote searchText to be passed?
2 REPLIES 2
kbenson
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2010
11:31 AM
Re: escaping spaces in URL
"SolveLLC" wrote:
searchText = screen.GetText()
print "search text: "; searchText
m.UrlBase = "http://somewebserver.com/web/"
m.Text = "/sample.php?text="
rhttp = NewHttp(m.UrlBase + m.Text + searchText)
rsp = rhttp.Http.GetToString()
I'm posting as a GET to a webserver. searchText is the result of input from the roKeyboardScreen. If I have spaces or reserved characters in searchText, it will print to the debug console, but the http GET silently fails.
My webserver will certainly take something like this http://somewebserver/web/sample.php?text=1111 3333
Is there anything I can do in Brightscript to quote searchText to be passed?
Actaully, the webserver won't, it just looks like it does. Browsers silently escape or urlencode (I always get the terms mixed up) anything in the address bar, so what your webserver actually sees is:
http://somewebserver/web/sample.php?text=1111%203333
If you can check the logs of the webserver, you should be able to confirm or refute this.
If it is the escaping that's the problem, you want is to escape the parameter value, but not the parameter name or URL. Look at the Escape and Unescape methods for the roURLTransfer object.
-- GandK Labs
Check out Reversi! in the channel store!
Check out Reversi! in the channel store!

SolveLLC
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2010
02:47 PM
Re: escaping spaces in URL
You were right. I use Escape on the parameter and it is working now. Thanks!