Levente Uzonyi uploaded a new version of WebClient-Core to project The Trunk:
http://source.squeak.org/trunk/WebClient-Core-ul.100.mcz ==================== Summary ==================== Name: WebClient-Core-ul.100 Author: ul Time: 21 April 2015, 6:50:26.091 am UUID: f5066327-2cbe-4505-b9b7-60b053f9cea8 Ancestors: WebClient-Core-topa.99 Introduced WebMessage >> #getContentWithProgress: to avoid code duplication in #contentWithProgress: and #getContent. Added support for gzip compression to GET requests. =============== Diff against WebClient-Core-topa.99 =============== Item was changed: ----- Method: WebClient>>httpGet:do: (in category 'methods') ----- httpGet: urlString do: aBlock "GET the response from the given url" "(WebClient httpGet: 'http://www.squeak.org') content" | request | self initializeFromUrl: urlString. request := self requestWithUrl: urlString. request method: 'GET'. userAgent ifNotNil:[request headerAt: 'User-Agent' put: userAgent]. + request headerAt: 'Accept-Encoding' put: 'gzip'. aBlock value: request. ^self sendRequest: request ! Item was changed: ----- Method: WebMessage>>contentWithProgress: (in category 'accessing') ----- contentWithProgress: progressBlock "Reads and caches available content and returns it." + ^content ifNil: [ content := self getContentWithProgress: progressBlock ]! - ^content ifNil:[ | length | - length := self contentLength. - content := (stream isBinary ifTrue:[ByteArray] ifFalse:[ByteString]) - new: (length ifNil:[1000]) - streamContents:[:s| self streamFrom: stream to: s size: length progress: progressBlock]].! Item was changed: ----- Method: WebMessage>>getContent (in category 'private') ----- getContent "Reads available content and returns it." + ^self getContentWithProgress: nil! - | length size buffer | - length := self contentLength. - size := length ifNil:[1000]. - buffer := ((stream isBinary ifTrue:[ByteArray] ifFalse:[ByteString]) - new: size) writeStream. - self streamFrom: stream to: buffer size: length progress: nil. - ^buffer position = size - ifTrue: [ buffer originalContents ] - ifFalse: [ buffer contents ]! Item was added: + ----- Method: WebMessage>>getContentWithProgress: (in category 'private') ----- + getContentWithProgress: progressBlockOrNil + "Reads available content and returns it." + + | length result | + length := self contentLength. + result := (stream isBinary ifTrue:[ ByteArray ] ifFalse: [ ByteString ]) + new: (length ifNil: [ 1000 ]) + streamContents: [ :outputStream | + self + streamFrom: stream + to: outputStream + size: length + progress: progressBlockOrNil ]. + (self headerAt: 'content-encoding') = 'gzip' ifFalse: [ ^result ]. + ^(GZipReadStream on: result) upToEnd + ! |
[copied to http://ss3.gemtalksystems.com/ss/WebClient/ ]
On 21.04.2015, at 05:08, [hidden email] wrote: > Levente Uzonyi uploaded a new version of WebClient-Core to project The Trunk: > http://source.squeak.org/trunk/WebClient-Core-ul.100.mcz > > ==================== Summary ==================== > > Name: WebClient-Core-ul.100 > Author: ul > Time: 21 April 2015, 6:50:26.091 am > UUID: f5066327-2cbe-4505-b9b7-60b053f9cea8 > Ancestors: WebClient-Core-topa.99 > > Introduced WebMessage >> #getContentWithProgress: to avoid code duplication in #contentWithProgress: and #getContent. > Added support for gzip compression to GET requests. > > =============== Diff against WebClient-Core-topa.99 =============== > > Item was changed: |
Free forum by Nabble | Edit this page |