Issue2894

classification
Title: urllib2 POST > 64k fails (RESOLVED)
Type: crash Severity: normal
Components: Library Versions: Jython 2.7.2
Milestone:
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: gbach, jeff.allen, r_walter
Priority: Keywords:

Created on 2020-05-26.09:20:17 by gbach, last changed 2022-06-13.12:00:00 by jeff.allen.

Files
File name Uploaded Description Edit Remove
post64k.py gbach, 2020-05-26.09:20:17
diff_smtplib.py gbach, 2020-08-17.18:08:14
Messages
msg13064 (view) Author: Gunter (gbach) Date: 2020-05-26.09:20:17
When urllib2-POSTing data > 64k the request times out and returns:

httplib.BadStatusLine: ''

<= 64k works fine.

Tested in newest (2.7.2 and 2.7.2b3, 2.7.2b2).
msg13066 (view) Author: Gunter (gbach) Date: 2020-05-26.09:21:25
To test modify line 5 to make the request bigger than 64k
msg13118 (view) Author: Gunter (gbach) Date: 2020-08-17.16:11:40
Sending mails with smtplib.py seems to suffer the same issue.
When sending an message > 64k (e.g. adding an attachment) the system stops for 5 minutes and then reports:
smtplib.SMTPServerDisconnected: Server not connected
msg13120 (view) Author: Gunter (gbach) Date: 2020-08-17.18:08:14
I managed to create a workaround:
removing sock.sendall in smtplib.py and replacing it by sending out 0xffff-sized chunks.
Implementation is inefficient but works...
msg13122 (view) Author: Gunter (gbach) Date: 2020-08-17.18:09:08
...workaround is only for sending mails of course!
msg13124 (view) Author: Gunter (gbach) Date: 2020-08-19.08:49:27
Inspired by my own workaround ;-)
Found the issue in _socket.py:

-    sendall = send   # FIXME see note above!

replace with:

    def sendall(self, data, flags=0):
        chunk_size = 8192
        length = len(data)
        data_view = memoryview(data)
        idx = 0
        while idx < length:
            bytes_sent = self.send(data_view[idx:idx + chunk_size], flags=flags)
            idx += bytes_sent

then all is working.

(Sorry for not making a proper Whatever-Git-Pull-Request/Hg-Thingy...)
msg13164 (view) Author: Roland Walter (r_walter) Date: 2021-08-24.16:29:55
This is a duplicate of https://bugs.jython.org/issue2840
msg13228 (view) Author: Jeff Allen (jeff.allen) Date: 2022-06-13.12:00:00
Handle as https://github.com/jython/jython/issues/60 and PR https://github.com/jython/jython/pull/185 believed to fix.
History
Date User Action Args
2022-06-13 12:00:00jeff.allensetstatus: open -> closed
resolution: duplicate
messages: + msg13228
nosy: + jeff.allen
2021-08-24 16:29:55r_waltersetnosy: + r_walter
messages: + msg13164
2020-08-19 08:49:35gbachsettitle: urllib2 POST > 64k fails -> urllib2 POST > 64k fails (RESOLVED)
2020-08-19 08:49:27gbachsetmessages: + msg13124
severity: major -> normal
2020-08-17 18:09:08gbachsetmessages: + msg13122
2020-08-17 18:08:15gbachsetfiles: + diff_smtplib.py
messages: + msg13120
severity: urgent -> major
2020-08-17 16:11:40gbachsetmessages: + msg13118
severity: major -> urgent
2020-06-24 14:24:43gbachsetcomponents: + Library
2020-05-26 09:21:25gbachsetmessages: + msg13066
2020-05-26 09:20:17gbachcreate