Skip to content

Add RequestBody.sha256()#9109

Merged
swankjesse merged 5 commits intosquare:masterfrom
martinbonnin:sha256
Oct 7, 2025
Merged

Add RequestBody.sha256()#9109
swankjesse merged 5 commits intosquare:masterfrom
martinbonnin:sha256

Conversation

@martinbonnin
Copy link
Copy Markdown
Contributor

Follow up from #9107

Comment thread okhttp/api/android/okhttp.api Outdated
Comment thread okhttp/src/commonJvmAndroid/kotlin/okhttp3/RequestBody.kt Outdated
Comment thread okhttp/src/commonJvmAndroid/kotlin/okhttp3/RequestBody.kt Outdated
Comment thread okhttp/src/jvmTest/kotlin/okhttp3/RequestBodyTest.kt Outdated
/**
* Returns the SHA-256 hash of this [RequestBody]
*/
fun sha256(): ByteString {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this have a verb, like "compute", given that it's doing something expensive (from an I/O perspective)?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think making it a function and not a val means we have freedom to do something expensive.

BUT! It should declare @Throws(IOException::class)

@swankjesse swankjesse merged commit 112a19d into square:master Oct 7, 2025
26 checks passed
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.

3 participants