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

commits at source.squeak.org commits at source.squeak.org
Thu Sep 15 22:23:06 UTC 2016


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].
  !



More information about the Squeak-dev mailing list