[Pkg] The Trunk: WebClient-Core-topa.110.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Sep 18 14:35:36 UTC 2017
Tobias Pape uploaded a new version of WebClient-Core to project The Trunk:
http://source.squeak.org/trunk/WebClient-Core-topa.110.mcz
==================== Summary ====================
Name: WebClient-Core-topa.110
Author: topa
Time: 18 September 2017, 4:35:29.15331 pm
UUID: 943ee269-4662-4ae7-ad63-2e5b9fce11b1
Ancestors: WebClient-Core-topa.109
fix handling of IPv6 literals in urls
=============== Diff against WebClient-Core-topa.109 ===============
Item was changed:
----- Method: WebClient>>proxyConnect (in category 'initialize') -----
proxyConnect
"Send a proxy CONNECT request to connect to a remote host via the chosen proxy server"
| uri request repeatAuth response |
+ uri := self serverUrlName,':', self serverPort.
- uri := self serverName,':', self serverPort.
request := self newRequest.
request method: 'CONNECT'.
request rawUrl: uri.
[repeatAuth := false.
"The proxy response may use Connection: Close; reconnect when that happens"
self isConnected ifFalse:[
stream := SocketStream openConnectionToHostNamed: lastServer port: lastPort.
stream timeout: timeout.
].
debugLog ifNotNil:[
request writeOn: debugLog.
debugLog flush.
].
"Don't use 'self writeRequestOn:' since this will insert both cookies
as well as modify the url target when a proxy is present"
request writeOn: stream.
stream flush.
response := request newResponse readFrom: stream.
debugLog ifNotNil:[
response writeOn: debugLog.
debugLog flush.
].
"Handle authentication if needed"
(self allowAuth and:[response code = 407]) ifTrue:[
"Eat up the content of the previous response"
response content.
repeatAuth := self authenticate: request from: response.
].
repeatAuth] whileTrue.
^response!
Item was changed:
----- Method: WebClient>>sendRequest:contentBlock: (in category 'sending') -----
sendRequest: request contentBlock: contentBlock
"Send an http request"
| response repeatRedirect repeatAuth |
"XXXX: Fixme. Pre-authenticate the request if we have valid auth credentials"
redirections := Dictionary new.
["The outer loop handles redirections"
repeatRedirect := false.
"Always update the host header due to redirect"
request headerAt: 'Host' put: server.
["The inner loop handles authentication"
repeatAuth := false.
"Connect can fail if SSL proxy CONNECT is involved"
self connect ifNotNil:[:resp| ^resp].
"Write the request to the debugLog if present"
debugLog ifNotNil:[self writeRequest: request on: debugLog].
"Send the request itself"
self writeRequest: request on: stream.
contentBlock value: stream.
response := request newResponse readFrom: stream.
response url: (scheme, '://', server, request rawUrl).
debugLog ifNotNil:[
response writeOn: debugLog.
debugLog flush.
].
response setCookiesDo:[:cookie|
+ self acceptCookie: cookie host: self serverUrlName path: request url.
- self acceptCookie: cookie host: self serverName path: request url.
].
accessLog ifNotNil:[
WebUtils logRequest: request response: response on: accessLog
].
"Handle authentication if needed"
(self allowAuth and:[response code = 401 or:[response code = 407]]) ifTrue:[
"Eat up the content of the previous response"
response content.
repeatAuth := self authenticate: request from: response.
].
repeatAuth] whileTrue.
"Flush previous authState.
XXXX: Fixme. authState must be preserved for pre-authentication of requests."
self flushAuthState.
"Handle redirect if needed"
(self allowRedirect and:[response isRedirect]) ifTrue:[
"Eat up the content of the previous response"
response content.
repeatRedirect := self redirect: request from: response.
].
repeatRedirect] whileTrue:[
"When redirecting, remove authentication headers"
request removeHeader: 'Authorization'.
request removeHeader: 'Proxy-Authorization'.
].
"If the response is not a success, eat up its content"
(response isSuccess or:[response isInformational]) ifFalse:[response content].
^response!
Item was changed:
----- Method: WebClient>>serverName (in category 'accessing') -----
serverName
"Returns the name part of the server:port description"
+
+ | serverUrlName |
+ serverUrlName := self serverUrlName.
+ ^ (serverUrlName includes: $[)
+ ifTrue: [serverUrlName copyFrom: 2 to: serverUrlName size - 1]
+ ifFalse: [serverUrlName]!
-
- ^server copyUpTo: $:!
Item was changed:
----- Method: WebClient>>serverPort (in category 'accessing') -----
serverPort
"Returns the port of the server:port description"
+ (self server copyAfterLast: $:)
+ ifNotEmpty:[:portString|
+ portString isAllDigits
+ ifTrue: [^ portString asInteger]].
+ ^ self defaultPort!
- ^(server copyAfter: $:)
- ifEmpty:[self defaultPort]
- ifNotEmpty:[:portString| portString asInteger].
- !
Item was added:
+ ----- Method: WebClient>>serverUrlName (in category 'accessing') -----
+ serverUrlName
+ "Returns the name part of the server:port description in the way it would appear in an Url"
+
+ ^ (self server includes: $[)
+ ifTrue: [self server copyUpThrough: $] ]
+ ifFalse: [self server copyUpToLast: $:]!
More information about the Packages
mailing list