<div dir="auto">Should Monticello really be responsible to deal with this? Or should it rather be the WebClient itself?<div dir="auto"><br></div><div dir="auto">    client isConnected ifFalse: [ client close ]</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr"> <<a href="mailto:commits@source.squeak.org" target="_blank" rel="noreferrer">commits@source.squeak.org</a>> schrieb am Fr., 20. Sep. 2019, 01:51:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Levente Uzonyi uploaded a new version of Monticello to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Monticello-ul.701.mcz" rel="noreferrer noreferrer noreferrer" target="_blank">http://source.squeak.org/trunk/Monticello-ul.701.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Monticello-ul.701<br>
Author: ul<br>
Time: 20 September 2019, 1:49:22.872448 am<br>
UUID: 6200146e-6bc8-483d-b784-34aeccaaa967<br>
Ancestors: Monticello-pre.700<br>
<br>
- assume that WebClient is always present in the image when Monticello is. This makes the Monticello package depend on the WebClient-Core package.<br>
- 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.<br>
- use the same code instead of the HTTPSocket fallback in MCHttpRepository>>httpGet:arguments: when the #useSharedWebClientInstance preference is disabled<br>
<br>
=============== Diff against Monticello-pre.700 ===============<br>
<br>
Item was changed:<br>
  ----- Method: MCHttpRepository class>>useSharedWebClientInstance (in category 'preferences') -----<br>
  useSharedWebClientInstance<br>
<br>
        <preference: 'Use shared WebClient instance'<br>
                category: 'Monticello'<br>
                description: 'When true, use a shared WebClient instance to speed up downloads from MCHttpRepositories. Requires WebClient to be present.'<br>
                type: #Boolean><br>
+       ^UseSharedWebClientInstance ifNil: [ true ]!<br>
-       ^UseSharedWebClientInstance ifNil: [ Smalltalk hasClassNamed: #WebClient ]!<br>
<br>
Item was changed:<br>
  ----- Method: MCHttpRepository>>httpGet:arguments: (in category 'private') -----<br>
  httpGet: url arguments: arguments<br>
<br>
        | progress urlString client  response result |<br>
-       self class useSharedWebClientInstance ifFalse: [<br>
-               ^HTTPSocket httpGet: url args: arguments user: self user passwd: self password ].<br>
        progress := [ :total :amount |<br>
                HTTPProgress new <br>
                        total: total;<br>
                        amount: amount;<br>
                        signal: 'Downloading...' ].<br>
        urlString := arguments<br>
                ifNil: [ url ]<br>
                ifNotNil: [ <br>
                        | queryString |<br>
+                       queryString := WebUtils encodeUrlEncodedForm: arguments.<br>
-                       queryString := (Smalltalk classNamed: #WebUtils) encodeUrlEncodedForm: arguments.<br>
                        (url includes: $?)<br>
                                ifTrue: [ url, '&', queryString ]<br>
                                ifFalse: [ url, '?', queryString ] ].<br>
+       self class useSharedWebClientInstance ifTrue: [<br>
+               "Acquire webClient by atomically storing it in the client variable and setting its value to nil."<br>
+               client := webClient.<br>
+               webClient := nil ].<br>
+       client <br>
+               ifNil: [ client := WebClient new ]<br>
+               ifNotNil: [ <br>
+                       "Attempt to avoid an error on windows by recreating the underlying stream."<br>
+                       client isConnected ifFalse: [ client close ] ].<br>
-       "Acquire webClient by atomically storing it in the client variable and setting its value to nil."<br>
-       client := webClient.<br>
-       webClient := nil.<br>
-       client ifNil: [ client := (Smalltalk classNamed: #WebClient) new ].<br>
        response := client<br>
                username: self user;<br>
                password: self password;<br>
                httpGet: urlString do: [ :request |<br>
                        request<br>
                                headerAt: 'Authorization' put: 'Basic ', (self user, ':', self password) base64Encoded;<br>
                                headerAt: 'Connection' put: 'Keep-Alive';<br>
                                headerAt: 'Accept' put: '*/*' ].<br>
        result := (response code between: 200 and: 299) <br>
                ifFalse: [<br>
                        response content. "Make sure content is read."<br>
                        nil ]<br>
                ifTrue: [ (RWBinaryOrTextStream with: (response contentWithProgress: progress)) reset ].<br>
+       self class useSharedWebClientInstance<br>
+               ifTrue: [<br>
+                       "Save the WebClient instance for reuse, but only if there is no client cached."<br>
+                       webClient  <br>
+                               ifNil: [ webClient := client ]<br>
+                               ifNotNil: [ client close ] ]<br>
+               ifFalse: [ client close ].<br>
+       result ifNil: [ NetworkError signal: 'Could not access ', location ].<br>
+       ^result!<br>
-       "Save the WebClient instance for reuse, but only if there is no client cached."<br>
-       webClient  <br>
-               ifNil: [ webClient := client ]<br>
-               ifNotNil: [ client close ].<br>
-       ^result ifNil: [<br>
-               NetworkError signal: 'Could not access ', location.<br>
-               nil ]!<br>
<br>
<br>
</blockquote></div>