FAQ
This is on apache 1.3 python 2.2 (straight up cgi) on a windows
machine

The following is the code I have

#!d:\progra~1\python22\python.exe
buf = (open("generic.gif", "rb")).read()

print """Content-Type: image/gif
Content-Length: %d
"""%(len(buf))
print buf


This code shows the gif perfectly fine under LINUX running APACHE 1.3
and python 1.5

but it shows a half truncated and mutated image on WINDOWS runnin
APACHE 1.3 and python 2.2

Can anyone tell me why? Is this a result of some internal change from
python 1.5 to python 2.2 or is it a linux vs. windows issue??

thanks in advance

Search Discussions

  • Skip Montanaro at May 7, 2003 at 1:06 am
    Seung> This is on apache 1.3 python 2.2 (straight up cgi) on a windows
    Seung> machine

    Seung> The following is the code I have

    Seung> #!d:\progra~1\python22\python.exe
    Seung> buf = (open("generic.gif", "rb")).read()

    Seung> print """Content-Type: image/gif
    Seung> Content-Length: %d
    Seung> """%(len(buf))
    Seung> print buf

    Look here:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65443

    Should get you started.

    Skip
  • Brian Quinlan at May 7, 2003 at 1:09 am

    print """Content-Type: image/gif
    Content-Length: %d
    """%(len(buf))
    print buf
    At the very least you are corrupting the GIF by an extra EOL character.
    Try:

    sys.stdout.write(buf)

    Cheers,
    Brian
  • Seung Chan Lim at May 7, 2003 at 6:46 am

    print """Content-Type: image/gif
    Content-Length: %d
    """%(len(buf))
    print buf
    At the very least you are corrupting the GIF by an extra EOL character.
    Try:

    sys.stdout.write(buf)
    actually, no... the content-length header takes care of that extra EOL
    character. ;)

    Thanks Skip, that URL is exactly what I needed

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65443

    slim
  • Brian Quinlan at May 7, 2003 at 4:38 pm

    actually, no... the content-length header takes care of that extra EOL
    character. ;)
    Actually, yes :-)

    Some clients like the length specified in the header to match the actual
    length. Maybe you can get away with it most of the time but it is
    probably not a good idea.

    Cheers,
    Brian

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMay 7, '03 at 12:51a
activeMay 7, '03 at 4:38p
posts5
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase