Skip to content

NTLM: cloneable body - #821

Merged
technoweenie merged 2 commits into
WillHipschman-ntlmfrom
ntlm-cloneable-body
Nov 16, 2015
Merged

technoweenie merged 2 commits into
WillHipschman-ntlmfrom
ntlm-cloneable-body

Conversation

@technoweenie

Copy link
Copy Markdown
Contributor

This is a proposal to merge into #820. It's complicated enough that I think it could use its own review.

Instead of buffering the entire request body into an in-memory byte buffer, this uses an internal cloneableBody type that only buffers up to 1MB. Any overflow is then written to a local temp file. This type can also clone itself without reading the body again. It simply creates a new struct with the same 1MB byte buffer, and re-opens the temp file.

Also, assuming all file handles are properly closed, a cloneableBody buffer will only delete the tempfile when the last one is closed.

Comment thread lfs/ntlm.go Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would change b to body, f to file, etc. It makes reading the code easier :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Some internal go code uses short vars like this. The go community seems to favor shorter names like that. But I think I learn more towards your opinion on this :)

@WillHipschman

Copy link
Copy Markdown

Other than some variable names this looks awesome.

technoweenie added a commit that referenced this pull request Nov 16, 2015
@technoweenie
technoweenie merged commit 7225d04 into WillHipschman-ntlm Nov 16, 2015
@technoweenie
technoweenie deleted the ntlm-cloneable-body branch November 16, 2015 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants