-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When the content-length and the actual data available differ (i.e. there are not enough bytes left to read before EOF), which is an error in any case, the response was different between a ZnStringEntity and a ZnByteArrayEntity. Now they behave the same. Furthermore, in ZnUtils class>>#streamFrom:to:size: there was a read that did not check the amount read.
- Loading branch information
Sven Van Caekenberghe
committed
Aug 31, 2023
1 parent
a1e4d39
commit f8c23a6
Showing
3 changed files
with
15 additions
and
16 deletions.
There are no files selected for viewing
16 changes: 7 additions & 9 deletions
16
repository/Zinc-HTTP.package/ZnByteArrayEntity.class/instance/readFrom..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
initialize-release | ||
readFrom: stream | ||
|
||
self contentLength | ||
ifNil: [ | ||
self bytes: (ZnUtils readUpToEnd: stream limit: (ZnCurrentOptions at: #maximumEntitySize)). | ||
self contentLength: self bytes size | ||
] | ||
ifNotNil: [ | byteArray | | ||
|
||
self contentLength: self bytes size ] | ||
ifNotNil: [ | byteArray readCount | | ||
self contentLength > (ZnCurrentOptions at: #maximumEntitySize) | ||
ifTrue: [ ZnEntityTooLarge signal ]. | ||
byteArray := ByteArray ofSize: self contentLength. | ||
self contentLength > ZnUtils streamingBufferSize | ||
readCount := self contentLength > ZnUtils streamingBufferSize | ||
ifTrue: [ ZnUtils streamFrom: stream to: byteArray writeStream size: self contentLength ] | ||
ifFalse: [ stream next: self contentLength into: byteArray ]. | ||
self bytes: byteArray | ||
] | ||
ifFalse: [ stream readInto: byteArray startingAt: 1 count: self contentLength ]. | ||
readCount = self contentLength | ||
ifTrue: [ self bytes: byteArray ] | ||
ifFalse: [ self bytes: (byteArray copyFrom: 1 to: readCount); contentLength: readCount ] ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters