[squeak-dev] The Trunk: Monticello-ul.701.mcz
Jakob Reschke
forums.jakob at resfarm.de
Fri Sep 20 04:01:11 UTC 2019
Should Monticello really be responsible to deal with this? Or should it
rather be the WebClient itself?
client isConnected ifFalse: [ client close ]
<commits at source.squeak.org> schrieb am Fr., 20. Sep. 2019, 01:51:
> Levente Uzonyi uploaded a new version of Monticello to project The Trunk:
> http://source.squeak.org/trunk/Monticello-ul.701.mcz
>
> ==================== Summary ====================
>
> Name: Monticello-ul.701
> Author: ul
> Time: 20 September 2019, 1:49:22.872448 am
> UUID: 6200146e-6bc8-483d-b784-34aeccaaa967
> Ancestors: Monticello-pre.700
>
> - assume that WebClient is always present in the image when Monticello is.
> This makes the Monticello package depend on the WebClient-Core package.
> - when using the shared WebClient instance during downloads, check if the
> client is still connected. If the client is not connected, e.g. the image
> was restarted, force the recreation of its stream by sending #close to the
> client.
> - use the same code instead of the HTTPSocket fallback in
> MCHttpRepository>>httpGet:arguments: when the #useSharedWebClientInstance
> preference is disabled
>
> =============== Diff against Monticello-pre.700 ===============
>
> Item was changed:
> ----- Method: MCHttpRepository class>>useSharedWebClientInstance (in
> category 'preferences') -----
> useSharedWebClientInstance
>
> <preference: 'Use shared WebClient instance'
> category: 'Monticello'
> description: 'When true, use a shared WebClient instance
> to speed up downloads from MCHttpRepositories. Requires WebClient to be
> present.'
> type: #Boolean>
> + ^UseSharedWebClientInstance ifNil: [ true ]!
> - ^UseSharedWebClientInstance ifNil: [ Smalltalk hasClassNamed:
> #WebClient ]!
>
> Item was changed:
> ----- Method: MCHttpRepository>>httpGet:arguments: (in category
> 'private') -----
> httpGet: url arguments: arguments
>
> | progress urlString client response result |
> - self class useSharedWebClientInstance ifFalse: [
> - ^HTTPSocket httpGet: url args: arguments user: self user
> passwd: self password ].
> progress := [ :total :amount |
> HTTPProgress new
> total: total;
> amount: amount;
> signal: 'Downloading...' ].
> urlString := arguments
> ifNil: [ url ]
> ifNotNil: [
> | queryString |
> + queryString := WebUtils encodeUrlEncodedForm:
> arguments.
> - queryString := (Smalltalk classNamed: #WebUtils)
> encodeUrlEncodedForm: arguments.
> (url includes: $?)
> ifTrue: [ url, '&', queryString ]
> ifFalse: [ url, '?', queryString ] ].
> + self class useSharedWebClientInstance ifTrue: [
> + "Acquire webClient by atomically storing it in the client
> variable and setting its value to nil."
> + client := webClient.
> + webClient := nil ].
> + client
> + ifNil: [ client := WebClient new ]
> + ifNotNil: [
> + "Attempt to avoid an error on windows by
> recreating the underlying stream."
> + client isConnected ifFalse: [ client close ] ].
> - "Acquire webClient by atomically storing it in the client variable
> and setting its value to nil."
> - client := webClient.
> - webClient := nil.
> - client ifNil: [ client := (Smalltalk classNamed: #WebClient) new ].
> response := client
> username: self user;
> password: self password;
> httpGet: urlString do: [ :request |
> request
> headerAt: 'Authorization' put: 'Basic ',
> (self user, ':', self password) base64Encoded;
> headerAt: 'Connection' put: 'Keep-Alive';
> headerAt: 'Accept' put: '*/*' ].
> result := (response code between: 200 and: 299)
> ifFalse: [
> response content. "Make sure content is read."
> nil ]
> ifTrue: [ (RWBinaryOrTextStream with: (response
> contentWithProgress: progress)) reset ].
> + self class useSharedWebClientInstance
> + ifTrue: [
> + "Save the WebClient instance for reuse, but only
> if there is no client cached."
> + webClient
> + ifNil: [ webClient := client ]
> + ifNotNil: [ client close ] ]
> + ifFalse: [ client close ].
> + result ifNil: [ NetworkError signal: 'Could not access ', location
> ].
> + ^result!
> - "Save the WebClient instance for reuse, but only if there is no
> client cached."
> - webClient
> - ifNil: [ webClient := client ]
> - ifNotNil: [ client close ].
> - ^result ifNil: [
> - NetworkError signal: 'Could not access ', location.
> - nil ]!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190920/17158095/attachment.html>
More information about the Squeak-dev
mailing list
|