[squeak-dev] The Trunk: WebClient-HTTP-cmm.6.mcz

Chris Muller asqueaker at gmail.com
Fri Sep 16 15:15:37 UTC 2016


Hi Xin, I'm sure this will sound odd, but I decided to keep as much of
Andreas' original code intact.

He may have simply meant, *not* binary, html is expressed in plain
text.  But, you are right that this creates a sort of ambiguity with
the "text/plain" MIME type.

Best,
  Chris

On Thu, Sep 15, 2016 at 10:48 PM, Xin Wang <dram.wang at gmail.com> wrote:
>
>
> 2016-09-16 6:22 GMT+08:00 <commits at source.squeak.org>:
>>
>> Chris Muller uploaded a new version of WebClient-HTTP to project The
>> Trunk:
>> http://source.squeak.org/trunk/WebClient-HTTP-cmm.6.mcz
>>
>> ==================== Summary ====================
>>
>> Name: WebClient-HTTP-cmm.6
>> Author: cmm
>> Time: 14 September 2016, 3:27:23.768768 pm
>> UUID: 900bff82-5c5e-478b-a08a-1ba7736a074d
>> Ancestors: WebClient-HTTP-cmm.4
>>
>> Accept text/html by default only when the user has not specified their own
>> mimeType.
>>
>> =============== Diff against WebClient-HTTP-cmm.4 ===============
>>
>> Item was changed:
>>   ----- Method: HTTPSocket class>>httpGetDocument:args:accept:request: (in
>> category '*webclient-http') -----
>>   httpGetDocument: url args: args accept: mimeType request: requestString
>>         "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"
>>
>>         "Note: To fetch raw data, you can use the MIME type
>> 'application/octet-stream'."
>>
>>         | client xhdrs resp urlString progress |
>>         "Normalize the url"
>>         urlString := (Url absoluteFromText: url) asString.
>>
>>         args ifNotNil: [
>>                 urlString := urlString, (self argString: args)
>>         ].
>>
>>         "Some raw extra headers which historically have been added"
>>         xhdrs := HTTPProxyCredentials,
>>                 HTTPBlabEmail,  "may be empty"
>>                 requestString.  "extra user request. Authorization"
>>
>>         client := WebClient new.
>>         ^[resp := client httpGet: urlString do:[:req|
>> +               "Add ACCEPT header, accept plain text by default."
>> +               req headerAt: 'Accept' put: (mimeType ifNil:
>> ['text/html']).
>> -               "Add ACCEPT header"
>> -               mimeType ifNotNil:[req headerAt: 'Accept' put: mimeType].
>>
>> -               "Always accept plain text"
>> -               req addHeader: 'Accept' value: 'text/html'.
>> -
>>                 "Add the additional headers"
>>                 (WebUtils readHeadersFrom: xhdrs readStream)
>>                         do:[:assoc| req addHeader: assoc key value: assoc
>> value]].
>>
>>         progress := [:total :amount|
>>                 (HTTPProgress new) total: total; amount: amount; signal:
>> 'Downloading...'
>>         ].
>>
>>         "Simulate old HTTPSocket return behavior"
>>         (resp code between: 200 and: 299)
>>                 ifTrue:[MIMEDocument contentType: resp contentType
>>                                 content: (resp contentWithProgress:
>> progress) url: url]
>>                 ifFalse:[resp asString, resp content].
>>         ] ensure:[client destroy].
>>   !
>>
>>
>
>
> Comment typo?
>
> I think “text/html" does not mean "plain text", as there is "text/plain".
>
>
> Regards,
> Xin Wang
>
>
>


More information about the Squeak-dev mailing list