Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] From "C" to Rebol: - decode-cgi-special/Object Methods

From: tim:johnsons-web at: 3-Aug-2001 9:59

It looks like the previous transmission on this topic munched the code. Here it is again: To recap: In the meantime, have a look at what I have below. Implementation - wise, these are "methods" for a large object .... they are evaluated by a "constructor" ; "helper" functions: no-data?: func[arg][either any[none? arg arg = false empty? arg] [return true][return false]] has-data?: func[arg][either any[none? arg arg = false empty? arg] [return false][return true]] ; data "fetch" method: read-data: func[/local tmp stdin dstr] [ either system/options/cgi/request-method = "POST"[ either (tmp: to-integer load any[system/options/cgi/content-length "0"])> 0[ stdin: make string! tmp ; allocate storage space read-io system/ports/input stdin tmp return stdin ][none] ; data string empty ][;OR dstr: system/options/cgi/query-string either has-data? dstr[dstr][none] ]; end either ]; end read-data -------------------- ; parses data-string into a block of alternating ; names and values. Both names and values are dehexed decode-data: func[/local cgi-form data-string][ either data-string: read-data[ data-string: dehex replace/all data-string "+" " " pairs: (length? pair-list: parse/all data-string "&=") / 2 ][none] ]; end decode-data ; I hope thats more readable. tim