Skip to content

HTTPConnection.send #61775

Description

@dspublicfreemailhu
BPO 17575
Nosy @Rosuav

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 = None
closed_at = <Date 2013-04-14.20:13:05.000>
created_at = <Date 2013-03-29.16:25:03.779>
labels = ['type-bug']
title = 'HTTPConnection.send'
updated_at = <Date 2013-04-14.20:13:04.998>
user = 'https://bugs.python.org/dspublicfreemailhu'

bugs.python.org fields:

activity = <Date 2013-04-14.20:13:04.998>
actor = 'dspublic@freemail.hu'
assignee = 'none'
closed = True
closed_date = <Date 2013-04-14.20:13:05.000>
closer = 'dspublic@freemail.hu'
components = []
creation = <Date 2013-03-29.16:25:03.779>
creator = 'dspublic@freemail.hu'
dependencies = []
files = []
hgrepos = []
issue_num = 17575
keywords = []
message_count = 3.0
messages = ['185501', '186794', '186949']
nosy_count = 3.0
nosy_names = ['Rosuav', 'dspublic@freemail.hu', 'Stephen.Tu']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue17575'
versions = ['Python 3.2', 'Python 3.3']

Activity

  1. dspublicfreemailhu commented on Mar 29, 2013

    dspublicfreemailhumannequin
    MannequinAuthor

    http.client modul, HTTPConnection object, send method

    Missing an "else" for self.sock.sendall(data) try block.

    ...
    if hasattr(data, "read") :
    if self.debuglevel > 0:
    print("sendIng a read()able")
    encode = False
    try:
    mode = data.mode
    except AttributeError:
    # io.BytesIO and other file-like objects don't have a mode
    # attribute.
    pass
    else:
    if "b" not in mode:
    encode = True
    if self.debuglevel > 0:
    print("encoding file using iso-8859-1")
    while 1:
    datablock = data.read(blocksize)
    if not datablock:
    break
    if encode:
    datablock = datablock.encode("iso-8859-1")
    self.sock.sendall(datablock)
    else: #missing else
    try:
    self.sock.sendall(data)
    except TypeError:
    if isinstance(data, collections.Iterable):
    for d in data:
    self.sock.sendall(d)
    else:
    raise TypeError("data should be a bytes-like object "
    "or an iterable, got %r" % type(data))

  2. StephenTu commented on Apr 13, 2013

    StephenTumannequin
    Mannequin

    I don't think this is a bug anymore in the codebase- looking at Lib/http/client.py, if hasattr(data, "read") is true, then the branch will return unconditionally.

            if hasattr(data, "read") :
                if self.debuglevel > 0: 
                    print("sendIng a read()able")
                encode = False
                try: 
                    mode = data.mode
                except AttributeError:
                    # io.BytesIO and other file-like objects don't have a `mode`
                    # attribute.
                    pass 
                else:
                    if "b" not in mode:
                        encode = True 
                        if self.debuglevel > 0: 
                            print("encoding file using iso-8859-1")
                while 1:
                    datablock = data.read(blocksize)
                    if not datablock:
                        break
                    if encode:
                        datablock = datablock.encode("iso-8859-1")
                    self.sock.sendall(datablock)
                return
  3. dspublicfreemailhu commented on Apr 14, 2013

    dspublicfreemailhumannequin
    MannequinAuthor

    Thank you Stephen.Tu for information. I think so, the "return" has been found ;-)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions