-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add copy of http.client with debugging #10998
base: main
Are you sure you want to change the base?
Add copy of http.client with debugging #10998
Conversation
|
else: | ||
# Amount is not given (unbounded read) so we must check self.length | ||
if self.length is None: | ||
s = self.fp.read() | ||
else: | ||
try: | ||
s = self._safe_read(self.length) | ||
except IncompleteRead: | ||
self._close_conn() | ||
raise | ||
self.length = 0 | ||
self._close_conn() # we read everything | ||
return s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
self._output(self._encode_request(request)) | ||
|
||
if self._http_vsn == 11: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# when used as Host header | ||
|
||
if host.find(':') >= 0: | ||
host_enc = b'[' + host_enc + b']' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 Code Quality Violation
use f-string or .format to format strings (...read more)
Concatenation of multiple strings is not efficient and make the code hard to read and understand.
Instead of concatenating multiple strings, use an f-string or a format string.
Learn More
# 2. the body is a file or iterable, but not a str or bytes-like | ||
# 3. Transfer-Encoding has NOT been explicitly set by the caller | ||
|
||
if 'content-length' not in header_names: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Save the method for use later in the response phase | ||
self._method = method | ||
|
||
url = url or '/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
class LineTooLong(HTTPException): | ||
def __init__(self, line_type): | ||
HTTPException.__init__(self, "got more than %d bytes when reading %s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 Code Quality Violation
HTTPException.__init__(self, "got more than %d bytes when reading %s" | |
super().__init__(self, "got more than %d bytes when reading %s" |
should call parent using super() (...read more)
Calling the parent constructor should be done by calling super()
, not by calling the parent object directly.
except: | ||
response.close() | ||
raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise ValueError('Invalid header value %r' % (values[i],)) | ||
|
||
value = b'\r\n\t'.join(values) | ||
header = header + b': ' + value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
occurrences are returned. Case is not important in the header name. | ||
|
||
""" | ||
name = name.lower() + ':' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mv = memoryview(body) | ||
return mv.nbytes | ||
except TypeError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BenchmarksBenchmark execution time: 2024-10-10 20:05:54 Comparing candidate commit 611e472 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 373 metrics, 51 unstable metrics. |
else: | ||
return ', '.join(headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try: | ||
import ssl | ||
except ImportError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else: | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is part of the investigation of the
IncompleteRead
issue in dogweb. It's not meant to be merged, just to be installed temporarily in the ITR shadow job in dogweb staging.Checklist
Reviewer Checklist