<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-09-16 23:15 GMT+08:00 Chris Muller <span dir="ltr"><<a href="mailto:asqueaker@gmail.com" target="_blank">asqueaker@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Xin, I'm sure this will sound odd, but I decided to keep as much of<br>
Andreas' original code intact.<br>
<br>
He may have simply meant, *not* binary, html is expressed in plain<br>
text. But, you are right that this creates a sort of ambiguity with<br>
the "text/plain" MIME type.<br>
<br>
Best,<br>
Chris<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div>Get it. Thanks!<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
On Thu, Sep 15, 2016 at 10:48 PM, Xin Wang <<a href="mailto:dram.wang@gmail.com">dram.wang@gmail.com</a>> wrote:<br>
><br>
><br>
> 2016-09-16 6:22 GMT+08:00 <<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>>:<br>
>><br>
>> Chris Muller uploaded a new version of WebClient-HTTP to project The<br>
>> Trunk:<br>
>> <a href="http://source.squeak.org/trunk/WebClient-HTTP-cmm.6.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/<wbr>trunk/WebClient-HTTP-cmm.6.mcz</a><br>
>><br>
>> ==================== Summary ====================<br>
>><br>
>> Name: WebClient-HTTP-cmm.6<br>
>> Author: cmm<br>
>> Time: 14 September 2016, 3:27:23.768768 pm<br>
>> UUID: 900bff82-5c5e-478b-a08a-<wbr>1ba7736a074d<br>
>> Ancestors: WebClient-HTTP-cmm.4<br>
>><br>
>> Accept text/html by default only when the user has not specified their own<br>
>> mimeType.<br>
>><br>
>> =============== Diff against WebClient-HTTP-cmm.4 ===============<br>
>><br>
>> Item was changed:<br>
>> ----- Method: HTTPSocket class>>httpGetDocument:args:<wbr>accept:request: (in<br>
>> category '*webclient-http') -----<br>
>> httpGetDocument: url args: args accept: mimeType request: requestString<br>
>> "Return the exact contents of a web object. Asks for the given<br>
>> MIME type. If mimeType is nil, use 'text/html'. An extra requestString may<br>
>> be submitted and must end with crlf. The parsed header is saved. Use a<br>
>> proxy server if one has been registered. tk 7/23/97 17:12"<br>
>><br>
>> "Note: To fetch raw data, you can use the MIME type<br>
>> 'application/octet-stream'."<br>
>><br>
>> | client xhdrs resp urlString progress |<br>
>> "Normalize the url"<br>
>> urlString := (Url absoluteFromText: url) asString.<br>
>><br>
>> args ifNotNil: [<br>
>> urlString := urlString, (self argString: args)<br>
>> ].<br>
>><br>
>> "Some raw extra headers which historically have been added"<br>
>> xhdrs := HTTPProxyCredentials,<br>
>> HTTPBlabEmail, "may be empty"<br>
>> requestString. "extra user request. Authorization"<br>
>><br>
>> client := WebClient new.<br>
>> ^[resp := client httpGet: urlString do:[:req|<br>
>> + "Add ACCEPT header, accept plain text by default."<br>
>> + req headerAt: 'Accept' put: (mimeType ifNil:<br>
>> ['text/html']).<br>
>> - "Add ACCEPT header"<br>
>> - mimeType ifNotNil:[req headerAt: 'Accept' put: mimeType].<br>
>><br>
>> - "Always accept plain text"<br>
>> - req addHeader: 'Accept' value: 'text/html'.<br>
>> -<br>
>> "Add the additional headers"<br>
>> (WebUtils readHeadersFrom: xhdrs readStream)<br>
>> do:[:assoc| req addHeader: assoc key value: assoc<br>
>> value]].<br>
>><br>
>> progress := [:total :amount|<br>
>> (HTTPProgress new) total: total; amount: amount; signal:<br>
>> 'Downloading...'<br>
>> ].<br>
>><br>
>> "Simulate old HTTPSocket return behavior"<br>
>> (resp code between: 200 and: 299)<br>
>> ifTrue:[MIMEDocument contentType: resp contentType<br>
>> content: (resp contentWithProgress:<br>
>> progress) url: url]<br>
>> ifFalse:[resp asString, resp content].<br>
>> ] ensure:[client destroy].<br>
>> !<br>
>><br>
>><br>
><br>
><br>
> Comment typo?<br>
><br>
> I think “text/html" does not mean "plain text", as there is "text/plain".<br>
><br>
><br>
> Regards,<br>
> Xin Wang<br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div></div>