[BUG][FIX] Put proxy authentication back into HTTPSocket ([closed] reporter updated Mantis ID 912)

Ken Causey ken at kencausey.com
Wed Apr 20 15:09:34 UTC 2005


Thank you for updating the fix on the existing Mantis report.

Ken Causey

On Tue, 2005-04-19 at 07:03 -0700, David Faught wrote:
> >From the changeSet preamble:
> Change Set:		HTTPAuthAgain2-daf
> Date:			19 April 2005
> Author:			Dave Faught
> 
> Enable proxy authentication again after it was removed by changes
> 6277HTTPSocketRedirectFix-st and
> 6651ExternalCleanup
> 
> This also fixes Mantix bug 912.
> 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Plan great trips with Yahoo! Travel: Now over 17,000 guides!
> http://travel.yahoo.com/p-travelguide
> plain text document attachment (HTTPAuthAgain2-daf.1.cs),
> "HTTPAuthAgain2-daf.1.cs"
> 'From Squeak3.8gamma of ''24 November 2004'' [latest update: #6662] on 19 April 2005 at 8:58:20 am'! "Change Set:		HTTPAuthAgain2-daf Date:			19 April 2005 Author:			Dave Faught Enable proxy authentication again after it was removed by changes 6277HTTPSocketRedirectFix-st and 6651ExternalCleanup"! !HTTPSocket class methodsFor: '*monticello-override' stamp: 'daf 4/19/2005 08:20'! 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'." 	| serverName serverAddr port sock header length bare page list firstData aStream index connectToHost connectToPort type newUrl | 	Socket initializeNetwork. 	bare := (url asLowercase beginsWith: 'http://') 				ifTrue: [url copyFrom: 8 to: url size] 				ifFalse: [url]. 	bare := bare copyUpTo: $#. 	"remove fragment, if specified" 	serverName := bare copyUpTo: $/. 	page := bare copyFrom: serverName size + 1 to: bare size. 	(serverName includes: $:) 		ifTrue: 			[index := serverName indexOf: $:. 			port := (serverName copyFrom: index + 1 to: serverName size) asNumber. 			serverName := serverName copyFrom: 1 to: index - 1] 		ifFalse: [port := self defaultPort]. 	page size = 0 ifTrue: [page := '/']. 	"add arguments" 	args ifNotNil: [page := page , (self argString: args)]. 	(self shouldUseProxy: serverName) 		ifTrue: 			[page := 'http://' , serverName , ':' , port printString , page. 			"put back 			together" 			connectToHost := HTTPProxyServer. 			connectToPort := HTTPProxyPort] 		ifFalse: 			[connectToHost := serverName. 			connectToPort := port]. 	serverAddr := NetNameResolver addressForName: connectToHost timeout: 20. 	serverAddr 		ifNil: [^'Could not resolve the server named: ' , connectToHost]. 	3 timesRepeat: 			[sock := HTTPSocket new. 			sock connectTo: serverAddr port: connectToPort. 			(sock waitForConnectionUntil: (self deadlineSecs: 30)) 				ifFalse: 					[Socket deadServer: connectToHost. 					sock destroy. 					^'Server ' , connectToHost , ' is not responding']. 			"Transcript cr;show: url; cr. 			Transcript show: page; cr." 			sock 				sendCommand: 'GET ' , page , ' HTTP/1.0' , CrLf 						, (mimeType ifNil: [''] ifNotNil: ['ACCEPT: ' , mimeType , CrLf]) 							, 'ACCEPT: text/html' , CrLf 						, HTTPProxyCredentials 						, HTTPBlabEmail , requestString 						, self userAgentString , CrLf 						, 'Host: ' , serverName 						, ':' , port printString 						, CrLf. 			"Always accept plain text" 			"may be empty" 			"extra user request. Authorization" 			"blank line 			automatically added" 			list := sock getResponseUpTo: CrLf , CrLf ignoring: (String with: CR). 			"list = header, CrLf, CrLf, 			beginningOfData" 			header := list at: 1. 			"Transcript show: page; cr; show: header; cr." 			firstData := list at: 3. 			header isEmpty 				ifTrue: [aStream := 'server aborted early'] 				ifFalse: 					["dig out some headers" 					sock header: header. 					length := sock getHeader: 'content-length'. 					length ifNotNil: [length := length asNumber]. 					type := sock getHeader: 'content-type'. 					sock responseCode first = $3 						ifTrue: 							[newUrl := sock getHeader: 'location'. 							newUrl ifNotNil: 									[Transcript 										show: 'redirecting to ' , newUrl; 										cr. 									sock destroy. 									newUrl := Url combine: url withRelative: newUrl. 									^self 										httpGetDocument: newUrl 										args: args 										accept: mimeType 										request: requestString]]. 					aStream := sock getRestOfBuffer: firstData totalLength: length. 					"a 400-series error" 					sock responseCode first = $4 ifTrue: [^header , aStream contents]]. 			sock destroy. 			"Always OK to destroy!!" 			aStream isString 				ifFalse: 					[^MIMEDocument 						contentType: type 						content: aStream contents 						url: url]. 			aStream = 'server aborted early' ifTrue: [^aStream]]. 	{ 		'HTTPSocket class>>httpGetDocument:args:accept:request:'. 		aStream. 		url} inspect. 	^'some other bad thing happened!!'! ]style[(71 2108 8 20 1 1727)f2b,f2,f1,f2,f1,f2! !
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20050420/cc4b7156/attachment.pgp


More information about the Squeak-dev mailing list