<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-09-16 6:22 GMT+08:00 <span dir="ltr"><<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Chris Muller uploaded a new version of WebClient-HTTP to project The 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 mimeType.<br>
<br>
=============== Diff against WebClient-HTTP-cmm.4 ===============<br>
<br>
Item was changed:<br>
----- Method: HTTPSocket class>>httpGetDocument:args:<wbr>accept:request: (in 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 MIME type. If mimeType is nil, use 'text/html'. An extra requestString may be submitted and must end with crlf. The parsed header is saved. Use a 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 '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: ['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 value]].<br>
<br>
progress := [:total :amount|<br>
(HTTPProgress new) total: total; amount: amount; signal: '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: progress) url: url]<br>
ifFalse:[resp asString, resp content].<br>
] ensure:[client destroy].<br>
!<br>
<br>
<br>
</blockquote></div><br></div><div class="gmail_extra"><br>Comment typo?<br><br></div><div class="gmail_extra">I think “text/html" does not mean "plain text", as there is "text/plain".<br><br><br></div><div class="gmail_extra">Regards,<br></div><div class="gmail_extra">Xin Wang<br></div></div>