CGI Redirect

Gabriel Ambuehl gabriel_ambuehl at buz.ch
Tue May 1 13:20:14 EDT 2001


-----BEGIN PGP SIGNED MESSAGE-----

Hello Ben,

Tuesday, May 01, 2001, 7:01:50 PM, you wrote:
>>Uuuh? Normally Content type and location headers shouldn't be mixed
as
>>the first one will disable all the others... For me, Location alone
>>works (Apache 1.3.19).
> Here's my code. Can you tell me where I'm going wrong? (Everything
gets
> replaced like it should, it's just the aforementioned error.)

As said, IMHO, you shouldn't have the
print "Content-type: text/html\n\n"
statement, since after that, no browser will care for the location
header anymore. There may be only ONE HTTP header per
response/request, IIRC.

>  >>>
> #!/usr/bin/python

> import os, sys, cgi, string

> FormData = cgi.FieldStorage()
> print "Content-type: text/html\n\n"

> Disallowed = ['\nTo:', '\nCc:', '\nBcc:']

> FormData = open("/apache/vhosts/bladechevy/New/test.html", "r")
> formstuff = ""
> while FormData.readline():
>    safe = string.maketrans("`|~!@#$%^&*()_+=:;{}[]",
"----------------------")
>    line =
>
string.replace(string.replace(string.replace(string.translate(FormData.
readline(),
> safe), "<input type-\"hidden\" name-\"", "."), "\" value-\"",
"----"),
"\">>", ".")
>    formstuff = string.join([formstuff,line])
> FormData.close()                    # close the file
> import smtplib
> server = smtplib.SMTP("localhost")
> server.sendmail("beno at thewebsons.com", "beno at thewebsons.com",
formstuff)
> server.quit()

> print "Location:http://bladechevy.com/"
> <<<
> TIA,
> BenO






Best regards,
 Gabriel

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.0.2i

iQEVAwUBOu7iQcZa2WpymlDxAQEoDQgAiNxNKTMMgpkCw7imDLNSuII+CcK9lTx6
X9JNiCfSng9S9fEzJXJUWKw3NQLpNC6Pb71DDIK/vEIDDvdXXKCTqhoCjD7xEAI1
Xwrb/DEq83oozWmkL2B1UDY9kAQhj+3auIXko4mK0J05Lp5Ixjxwu/sbnFNEu03g
RRUzqeYKY98kXO0i00GtzFQ+8sYZp/hv6qezMnOXuO1k0S0MTMgBVk4wKXaPELAv
bo579DWfxfiaN+6WbH4W6sSyo2rvn6KFyRL6db0V2k1V1CuHzt3rPSAmvrdb1nBC
p39Mj5w7KRp+IrNAGvBAi3i2wRTTu4bm+iXj8QADDUZbu+O3clzvdg==
=yg8B
-----END PGP SIGNATURE-----






More information about the Python-list mailing list