Re: Conversion of http escape characters

N.G.Smith (ngs@ukc.ac.uk)
Wed, 15 Jun 94 09:26:47 BST

In article <9406141640.AA02288@edison.eeel.nist.gov> mclay@eeel.nist.gov (Michael McLay) writes:
>N.G.Smith writes:
> > Is there a neat canned solution to the problem of converting the escaped
> > characters used in http back to normal characters?
>
>Here's my www.py module. It masks the CGI interface inside a class named
>FormContent. The constructor includes the algorithm that parses the
>name/value pairs and then the escaped characters that are returned by
>httpd.
>
>Michael

Thanks for the code.

>class FormContent:
> def __init__(self):
> if os.environ['QUERY_STRING'] != '':
> self.qs = os.environ['QUERY_STRING']
> else:
> self.qs = sys.stdin.readline()

But, is this bit safe as far as the http specification is concerned?

I'm no expert, but as I understood it, shouldn't it be ...

if os.environ['REQUEST_METHOD'] == 'POST':
self.qs = sys.stdin.read(int(os.environ['CONTENT_LENGTH']))
else:
self.qs = os.environ['QUERY_STRING']

... or similar.

Thanks again,

Neil.