Skip to content
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

Omit setting the length when in base64 transmission mode. #2006

Merged

Conversation

rkoumis
Copy link
Contributor

@rkoumis rkoumis commented Mar 12, 2024

Omit setting the length when in base64 transmission mode.

It was setting the file length, which was the wrong length for the encoded data.
The received data were truncated.

It was setting the file length, which was the wrong length for the
encoded data.
self.length = os.path.getsize(self.path)
if self.okay_to_send():
if self.encoding != BASE_64_ENCODING:
self.length = os.path.getsize(self.path)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix. Previously we were always setting the length. Now, we'll skip setting the length when base64 transmission is called for.


def write(self, httplog, sock):
if not self.length:
if not self.okay_to_send():
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't use self.length any longer to check if it's okay to send the file.

decoded = base64.b64decode(r.text + "==").decode()
assert "test data" in decoded
assert first_line in decoded
assert last_line in decoded
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure we receive even the very last line of the file.

@doomedraven doomedraven merged commit 0b9167d into kevoreilly:master Mar 12, 2024
5 checks passed
@doomedraven
Copy link
Collaborator

thanks

@rkoumis rkoumis deleted the base-64-send-file-dont-set-length branch November 18, 2024 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants