The Trunk: WebClient-Core-jr.104.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: WebClient-Core-jr.104.mcz

commits-2
Tobias Pape uploaded a new version of WebClient-Core to project The Trunk:
http://source.squeak.org/trunk/WebClient-Core-jr.104.mcz

==================== Summary ====================

Name: WebClient-Core-jr.104
Author: jr
Time: 3 January 2017, 2:00:53.087318 pm
UUID: d1ea9e44-934e-db44-9617-a57b408678fe
Ancestors: WebClient-Core-ul.103

fix: bogus chunked stream data if a later chunk is smaller than a previous one

also do not fetch the next chunk until its contents is requested

=============== Diff against WebClient-Core-ul.103 ===============

Item was changed:
  ----- Method: WebChunkedStream>>next: (in category 'accessing') -----
  next: anInteger
  "Answer the next anInteger elements of my collection.  overriden for simplicity"
 
+ [(position + anInteger > readLimit) and:[chunkSize ~= 0]]
- [(position + anInteger >= readLimit) and:[chunkSize ~= 0]]
  whileTrue:[self nextChunk].
 
  ^super next: anInteger
  !

Item was changed:
  ----- Method: WebChunkedStream>>nextChunk (in category 'accessing') -----
  nextChunk
  "Answer the next chunk from a message using chunked transfer encoding."
 
  | chunk |
  chunkSize = 0 ifTrue:[^'']. "read last chunk"
  chunkSize := Integer readFrom: (sourceStream upToAll: String crlf) asString base: 16.
  chunkSize = 0 ifFalse:[chunk := sourceStream next: chunkSize].
  sourceStream skip: 2. "CrLf"
  (chunkSize + readLimit - position) <= collection size ifTrue:[
  collection replaceFrom: 1 to: (readLimit-position) with: collection startingAt: position+1.
  readLimit := readLimit - position.
  position := 0.
  collection replaceFrom: readLimit+1 to: readLimit + chunkSize with: chunk startingAt: 1.
  readLimit := readLimit + chunkSize.
  ] ifFalse:[
+ position < readLimit
+ ifTrue: [collection := (collection copyFrom: position + 1 to: readLimit), chunk]
+ ifFalse: [collection := chunk].
+ position := 0.
+ readLimit := collection size.
- collection := collection, chunk.
- readLimit := readLimit + chunkSize.
  ].
  ^chunk
  !