Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ readEntityFromStream
chunkedStream := (isChunked := self isChunked) ifTrue: [ stream := ZnChunkedReadStream on: stream ] ifFalse: [ nil ].
self isGzipped
ifTrue: [
self hasContentLength ifTrue: [ stream := ZnLimitedReadStream on: stream limit: self contentLength ].
self hasContentLength
ifTrue: [ stream := ZnLimitedReadStream on: stream limit: self contentLength ]
ifFalse: [
"InflateStream asks its source for its position, which a socket stream cannot answer"
isChunked ifFalse: [ stream := ZnLimitedReadStream on: stream limit: SmallInteger maxVal ] ].
decodedEntityLength := nil.
stream := GZipReadStream on: stream ]
ifFalse: [ decodedEntityLength := self contentLength ].
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
testing
testGzippedUpToEndFromUnpositionableStream
| text compressed headers reader |
text := String streamContents: [ :out |
1 to: 50000 do: [ :each | out print: each; space ] ].
compressed := ByteArray streamContents: [ :out |
(GZipWriteStream on: out) nextPutAll: text asByteArray; close ].
(headers := ZnHeaders new)
at: 'Content-Type' put: 'text/plain';
at: 'Content-Encoding' put: 'gzip'.
(reader := ZnEntityReader new)
headers: headers;
stream: (ZnUnpositionableReadStream on: compressed readStream);
allowReadingUpToEnd.
self assert: reader readEntity contents equals: text
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
I am ZnUnpositionableReadStream. I wrap a read stream but, like a socket stream, I cannot tell my position.

I am used in tests to make sure readers do not depend on a positionable source.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instance creation
on: readStream
^ self new
setStream: readStream;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
testing
atEnd
^ stream atEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
testing
isBinary
^ true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
testing
isStream
^ true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
next: count
^ stream next: count
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
next: count into: collection startingAt: offset
^ stream next: count into: collection startingAt: offset
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
next
^ stream next
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
readInto: collection startingAt: offset count: count
^ stream readInto: collection startingAt: offset count: count
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialization
setStream: readStream
stream := readStream
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"commentStamp" : "",
"super" : "Object",
"category" : "Zinc-Tests",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"stream"
],
"name" : "ZnUnpositionableReadStream",
"type" : "normal"
}
Loading