Getting empty Post data
[1/4] from: sags:apollo:lv at: 21-Dec-2004 23:26
Hi, List! Beginner question: Why following script function by Mike Yaunish gives different output on different webservers: input-cgi: func [/stdin] [ stdin: make string! 15000 either system/options/cgi/request-method = "POST" [ read-io system/ports/input stdin 15000 return stdin ][ system/options/cgi/query-string ] ] On some servers this function returns false or none on empty Post data, but on others String: "" . So normaly I can't use this function in simple If or Either. So I rewrited the function: input-cgi: func [/stdin] [ data: make string! 15000 either system/options/cgi/request-method = "POST" [ read-io system/ports/input data 15000 outdata: data ][ outdata: system/options/cgi/query-string ] either outdata [ either ( string! = type? outdata ) and ( empty? outdata ) [ return false ][ return outdata ] ][ return false ] ] Are there some better ways? brgds Janeks
[2/4] from: SunandaDH:aol at: 21-Dec-2004 16:55
> Are there some better ways?
It's definitely a bug. The response is either an empty string or none depending on whether you are running under Unix/Linux or Windows (I forget which is which). In all my code, I leave the equivalent of input-cgi unpatched, and have an 'all to test for null data: if any [none? cgi-input "" = cgi-input ][ ;; code for no input fields ] Dunno if that is better, though, Sunanda
[3/4] from: SunandaDH:aol at: 30-Dec-2004 10:29
> In my case the diffrent responses does not comes from different > OSes. I got false: on Win2000 server and MS IIS, WinXP and Abyss > WebServ, while WinXP and KFWS gives: "" .
Apologies for not responding sooner. Your message never made it to my inbox. And, from reports from several other people, it may have been one of the messages that no one saw -- the ML is not well this season. Thanks for the testing on different platforms. Useful information
> Should I update input-cgi in scrips library?
The problem with that is that it would end up doing one or the other -- returning either none or an empty string. That may break existing code where people are running on just one platform and have opted for just one of the two tests. The problem isn't specifically with the code in the Library. It also affects Carl's own version of the same code, read-cgi: http://www.rebol.com/docs/words/wread-io.html I think the solution is to add a note to both the script in the Library and Carl's read-cgi to highlight the two possible results for null data. I'll update the Library script, and drop RT a feedback message. Thanks again, Sunanda.
[4/4] from: sags:apollo:lv at: 22-Dec-2004 21:16
On 21 Dec 2004 at 16:55, SunandaDH-aol.com wrote:
> It's definitely a bug.
Bug of what? Web serv, script, rebol? ;-)
> The response is either an empty string or none depending on whether > you are running under Unix/Linux or Windows (I forget which is > which).
In my case the diffrent responses does not comes from different OSes. I got false: on Win2000 server and MS IIS, WinXP and Abyss WebServ, while WinXP and KFWS gives: "" .
> In all my code, I leave the equivalent of input-cgi unpatched, and > have an 'all to test for null data:
<<quoted lines omitted: 4>>> ] > Dunno if that is better, though,
I like this better - it seems more readable. But I would rather include this in input-cgi, then I will have less to work on "bugs" in scripts that refferences to input-cgi and to make dependent scrips more cross platform. Should I update input-cgi in scrips library? brgds Janeks
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted