Skip to content

CGIHTTPServer.py POST bug using IE #34582

Closed

Description

@kasplat
mannequin
BPO 430160
Nosy @gvanrossum, @rhettinger
Files
  • patch001.txt: First-round fix for IE POST bug
  • windows posttest bug.zip: zip file containing html and CGIs to reproduce bug
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/rhettinger'
    closed_at = <Date 2003-06-29.05:07:37.000>
    created_at = <Date 2001-06-05.00:09:04.000>
    labels = ['OS-windows']
    title = 'CGIHTTPServer.py POST bug using IE'
    updated_at = <Date 2003-06-29.05:07:37.000>
    user = 'https://bugs.python.org/kasplat'

    bugs.python.org fields:

    activity = <Date 2003-06-29.05:07:37.000>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = None
    closer = None
    components = ['Windows']
    creation = <Date 2001-06-05.00:09:04.000>
    creator = 'kasplat'
    dependencies = []
    files = ['71', '72']
    hgrepos = []
    issue_num = 430160
    keywords = []
    message_count = 9.0
    messages = ['4952', '4953', '4954', '4955', '4956', '4957', '4958', '4959', '4960']
    nosy_count = 6.0
    nosy_names = ['gvanrossum', 'rhettinger', 'holdenweb', 'kasplat', 'kyrrigle', 'weoweo']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue430160'
    versions = []

    Activity

    1. kasplat commented on Jun 5, 2001

      kasplatmannequin
      MannequinAuthor

      From the readme included in the zip:
      This set of files shows a bug that occurs when doing
      POST requests via the CGIHTTPServer.py module in
      Python 2.1 The testpost.html file when accessed via
      Internet Explorer 5.5 from webserver.py should show
      this bug. On short POST requests IE will end up doing
      a second POST and then displaying an error message
      while longer POSTs will be followed by a second POST
      and then a GET.

      The problem appears to be specific to the interaction
      of IE and the handling of windows sockets in Python in
      the CGIHTTPServer.py module which relies on
      BaseHTTPServer.py, SocketServer.py...

      posttestwebserver.py is currently setup to use
      C:\tmp\testpost as the document root, so either move
      the "testpost" folder to C:\tmp or change the
      directory to wherever the testpost folder is located.
      Start the server using the .bat file and bring
      up .html page with something like:
      http://localhost/testpost.html

      The bug should occur when you try:
      Test short CGI response with POST
      or
      Test long CGI response with POST

      The other requests should work fine. The bug will
      occur regardless of whether IE is set to use HTTP/1.0
      or HTTP/1.1. The bug doesn't appear to occur when
      going through a simple proxy. You can also get the bug
      to occur using a remote IE client (either on a LAN or
      over the Net). In addition, it doesn't appear to
      matter whether running with unbuffered binary pipes
      (python -u) or not. I also tested against my modified
      CGIHTTPServer.py See the bug I posted at:
      http://sourceforge.net/tracker/?
      func=detail&atid=105470&aid=427345&group_id=5470

      My configuration:
      Windows 2000 Pro, SP2
      AMD 1.2GHz
      256MB RAM
      ActiveStatet Python 2.1 (build 210)
      Internet Explorer 5.5 (5.50.4522.1800)

      ka
      ---
      Mark Lutz said:
      "FWIW, I noticed today (in between lecturing a class)
      that on Windows, Python actually uses a special Python-
      coded socket.py library module, not the standard C-
      coded socket extension module. socket.py lives in the
      library directory; it does unique things for closes
      and deletes that may not make sense in all cases
      (e.g., the makefile call generates a class instance,
      not a true file object). It may also be trying to
      close the underlying socket twice. I don't have"

    2. holdenweb commented on Jul 17, 2001

      @holdenweb
      Member

      Logged In: YES
      user_id=88157

      Please note that I have observed this behavior on Windows
      98 using Python 2.0 (#8, Mar 7 2001, 16:04:37) [MSC 32 bit
      (Intel)] using the same build of IE, so it is not a Win2k-
      specific problem.

    3. kyrrigle commented on Mar 28, 2002

      kyrriglemannequin
      Mannequin

      Logged In: YES
      user_id=247536

      it appears that IE is sending 2 extra bytes ('\r\n') after
      the request data. and if you don't read those two extra
      bytes off, the window's socket handling gets messed up.

      the result is that a partial response is returned and the
      socket closed. IE tries to recover by re-POST'ing (which
      is behavior specified in the HTTP/1.1 RFC)... only they
      seem to add an embedded NULL the second time through, and
      the original socket problem happens again anyway.

      Try reading an extra 2 bytes from the rfile before sending
      your response and the problem should go away.

      not sure what the real fix for this should be?

    4. gvanrossum commented on Aug 5, 2002

      @gvanrossum
      Member

      Logged In: YES
      user_id=6380

      Steve, I'm assigning this bug to you. Feel free to check in
      a fix if you think one exists (as long as it doesn't break
      on Unix).

    5. holdenweb commented on Aug 16, 2002

      @holdenweb
      Member

      Logged In: YES
      user_id=88157

      This patch appears to fix the basic CGIHTTPServer behavior,
      at least for Unix and Wiondows platforms, but I'm not yet
      confident of its robustness in the face of Forking or threading
      mixin code. More later ...

    6. holdenweb commented on Jan 8, 2003

      @holdenweb
      Member

      Logged In: YES
      user_id=88157

      Should be fixed by patch 654910 committed today.

    7. weoweo commented on Jun 24, 2003

      weoweomannequin
      Mannequin

      Logged In: YES
      user_id=23630

      The patch might cause the server to loop endlessly, if the
      client has closed the connection. I suggest to change the
      patch as follows:

         while select.select([self.rfile], [], [], 0)[0]:
      -    waste = self.rfile.read(1)

      to

         while select.select([self.rfile], [], [], 0)[0]:
      +    if not self.rfile.read(1): break

      Maybe this is necessary for the Windows case as well ...

    8. gvanrossum commented on Jun 27, 2003

      @gvanrossum
      Member

      Logged In: YES
      user_id=6380

      Raymond, can you fix this? Seems simple enough...

    9. rhettinger commented on Jun 29, 2003

      @rhettinger
      Contributor

      Logged In: YES
      user_id=80475

      Applied to both the Unix and Windows flavors.
      Closing bug. Hopefully it stays dead this time.

      See Lib/CGIHTTPServer.py 1.31

    10. transferred this issue fromon Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions