[squeak-dev] The Trunk: WebClient-Core-topa.109.mcz
Levente Uzonyi
leves at caesar.elte.hu
Sat Jul 8 13:15:37 UTC 2017
Where does BrotliReadStream come from?
Also, #hasBindingOf: seems dangerous to use as it uses declarations
instead of bindings or both to look up the binding, while other
binding-related methods use bindings (e.g. #bindingOf:ifAbsent:,
#hasBindingThatBeginsWith:, #hideBinding:, #associationOrUndeclaredAt:).
It will probably work as long as there's only a single environment.
Levente
On Thu, 6 Jul 2017, commits at source.squeak.org wrote:
> Tobias Pape uploaded a new version of WebClient-Core to project The Trunk:
> http://source.squeak.org/trunk/WebClient-Core-topa.109.mcz
>
> ==================== Summary ====================
>
> Name: WebClient-Core-topa.109
> Author: topa
> Time: 6 July 2017, 3:27:22.152308 pm
> UUID: b795898b-9723-44ab-a429-bceb056f4b90
> Ancestors: WebClient-Core-topa.108
>
> As with content-type-charset, cope for content-encoding variability
>
> =============== Diff against WebClient-Core-topa.108 ===============
>
> Item was added:
> + ----- Method: WebClient>>contentDecoders (in category 'initialize') -----
> + contentDecoders
> +
> + | result |
> + result := nil.
> + (self class environment hasBindingOf: #GZipReadStream)
> + ifTrue: [result := 'gzip'].
> + (self class environment hasBindingOf: #BrotliReadStream)
> + ifTrue: [ result := result ifNil: ['br'] ifNotNil: [:r | r, ', br']].
> + ^ result!
>
> 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:[:ua | request headerAt: 'User-Agent' put: ua].
> + self contentDecoders ifNotNil: [:decoders | request headerAt: 'Accept-Encoding' put: decoders].
> - userAgent ifNotNil:[request headerAt: 'User-Agent' put: userAgent].
> - request headerAt: 'Accept-Encoding' put: 'gzip'.
> aBlock value: request.
> ^self sendRequest: request
> !
>
> Item was added:
> + ----- Method: WebMessage>>decoderForContentEncoding (in category 'private') -----
> + decoderForContentEncoding
> +
> + (self headerAt: 'content-encoding') = 'gzip'
> + ifTrue: [^ self class environment
> + at: #GZipReadStream ifAbsent: [self error: 'GZip encoded responses not supported']].
> + (self headerAt: 'content-encoding') = 'br'
> + ifTrue: [^ self class environment
> + at: #BrotliReadStream ifAbsent: [self error: 'Brotli encoded responses not supported']].
> + ^ nil!
>
> Item was changed:
> ----- 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 decoderForContentEncoding ifNotNil: [:decoder |
> + result := (decoder on: result) upToEnd].
> - (self headerAt: 'content-encoding') = 'gzip' ifTrue: [
> - result := (GZipReadStream on: result) upToEnd].
> self textConverterForContentType ifNotNil: [:converter |
> result := result convertFromWithConverter: converter].
> ^ result
> !
More information about the Squeak-dev
mailing list
|