[squeak-dev] The Trunk: Network-jcg.35.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Sep 1 07:46:53 UTC 2009


Joshua Gargus uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-jcg.35.mcz

==================== Summary ====================

Name: Network-jcg.35
Author: jcg
Time: 1 September 2009, 12:46:48 pm
UUID: 03bb9532-5287-40b1-bb29-ea33c8c3d4fd
Ancestors: Network-ar.34

Use 'foo base64Encoded' instead of '(Base64MimeConverter mimeEncode: foo readStream) contents'.

=============== Diff against Network-ar.34 ===============

Item was changed:
  ----- Method: HTTPSocket class>>httpPost:args:user:passwd: (in category 'get the page') -----
  httpPost: url args: args user: user passwd: passwd
  	| authorization |
+ 	authorization := (user , ':' , passwd) base64Encoded.
- 	authorization := (Base64MimeConverter mimeEncode: (user , ':' , passwd) readStream) contents.
  	^self 
  		httpPostDocument: url args: args accept: '*/*' 
  		request: 'Authorization: Basic ' , authorization , CrLf!

Item was changed:
  ----- Method: HTTPSocket class>>proxyUser:password: (in category 'proxy settings') -----
  proxyUser: userName password: password
  	"Store  HTTP 1.0 basic authentication credentials
  	Note: this is an ugly hack that stores your password
  	in your image.  It's just enought to get you going
  	if you use a firewall that requires authentication"
+ 	| encoded |
+ 	encoded := (userName, ':', password) base64Encoded.
+ 	HTTPProxyCredentials := 'Proxy-Authorization: Basic ' , encoded, String crlf!
- 
-     | stream encodedStream |
- 	stream := ReadWriteStream on: (String new: 16).
- 	stream nextPutAll: userName ,':' , password.
- 	encodedStream := Base64MimeConverter mimeEncode: stream.
- 	HTTPProxyCredentials := 'Proxy-Authorization: Basic ' , (encodedStream contents) , String crlf!

Item was changed:
  Stream subclass: #MailAddressTokenizer
  	instanceVariableNames: 'cachedToken text pos'
+ 	classVariableNames: 'CSNonAtom CSNonSeparators CSParens CSSpecials'
- 	classVariableNames: 'CSSpecials CSNonSeparators CSParens CSNonAtom'
  	poolDictionaries: ''
  	category: 'Network-RFC822'!
  
  !MailAddressTokenizer commentStamp: '<historical>' prior: 0!
  Divides an address into tokens, as specified in RFC 822.  Used by MailAddressParser.!

Item was changed:
  ----- Method: HTTPSocket class>>httpGet:args:user:passwd: (in category 'get the page') -----
  httpGet: url args: args user: user passwd: passwd
  	| authorization |
+ 	authorization := (user , ':' , passwd) base64Encoded.
- 	authorization := (Base64MimeConverter mimeEncode: (user , ':' , passwd) readStream) contents.
  	^self 
  		httpGet: url args: args accept: '*/*' 
  		request: 'Authorization: Basic ' , authorization , CrLf!

Item was changed:
  Object subclass: #ServerDirectory
  	instanceVariableNames: 'server directory type user passwordHolder group moniker altURL urlObject client loaderUrl eToyUserListUrl eToyUserList keepAlive encodingName'
+ 	classVariableNames: 'LocalEToyBaseFolderSpecs LocalEToyUserListUrls LocalProjectDirectories Servers'
- 	classVariableNames: 'LocalEToyUserListUrls LocalProjectDirectories LocalEToyBaseFolderSpecs Servers'
  	poolDictionaries: ''
  	category: 'Network-RemoteDirectory'!
  
  !ServerDirectory commentStamp: '<historical>' prior: 0!
  Holds all the information needed to read or write on a directory of an internet server.  I am used for FTP and HTTP (and STMP?  NNTP?).  The password policy is: unless it is a public password (like annomyous), clear all passwords before any snapshot.  There is a way to store passwords on the disk.
  
  server 		'www.disney.com'  or '123.34.56.08' or the ServerDirectory above me 
  			(if I am a subdirectory sharing the info in a master directory)
  directory 	'ftp/pubs/'  name of my directory within the server or superdirectory.
  			(for file://, directory is converted to local delimiters.)
  type 		#ftp	what you can do in this directory
  user 		'Jones45'
  password 	an instance of Password.  
  group 		an Association ('group name' -> an array of ServerDirectorys)
  			If this first one is down, try the next one.  Store on all of them.  I am in the list.
  moniker 	'Main Squeak Directory'  Description of this directory.
  altURL		When a FTP server holds some web pages, the altURL of those pages is often
  			different from the FTP directory.  Put the altURL here.  If the directory is 
  			'public_html/Squeak/', the altURL might be 'www.webPage.com/~kaehler2/
  			Squeak/'.
  urlObject	An instance of a subclass of Url.  It is very good at parsing complex urls.
  			Relative references.  file:// uses this.  Use this in the future instead of 
  			server and directory inst vars.
  socket		nil or an FTPSocket.  Only non-nil if the connection is being kept open
  			for multiple stores or retrievals.  
  loaderUrl	a partial url that is ised to invoke squeak in a browser and load a project.
  
  A normal call on some command like (aServer getFileNamed: 'foo') does not set 'socket'.  Socket being nil tells it to close the connection and destroy the socket after this one transcation.  If the caller stores into 'socket', then the same command does NOT close the 
  connection.  
  	Call 'openKeepFTP' or 'openGroup' to store into socket and keep the connection open.  It is up to the user to call 'quit' or 'closeGroup' later.
  
  DD openKeepFTP.
  Transcript cr; show: ((DD getFileNamed: '1198misc-tkKG.cs') next: 100).
  Transcript cr; show: ((DD getFileNamed: '1192multFinder-tkKF.cs') next: 100).
  DD quit.!

Item was changed:
  ----- Method: HTTPSocket class>>httpPut:to:user:passwd: (in category 'get the page') -----
  httpPut: contents to: url user: user passwd: passwd
  	"Upload the contents of the stream to a file on the server"
  
  	| bare serverName specifiedServer port page serverAddr authorization s list header firstData length aStream command |
  	Socket initializeNetwork.
   
  	"parse url"
  	bare := (url asLowercase beginsWith: 'http://') 
  		ifTrue: [url copyFrom: 8 to: url size]
  		ifFalse: [url].
  	serverName := bare copyUpTo: $/.
  	specifiedServer := serverName.
  	(serverName includes: $:) ifFalse: [ port := self defaultPort ] ifTrue: [
  		port := (serverName copyFrom: (serverName indexOf: $:) + 1 
  				to: serverName size) asNumber.
  		serverName := serverName copyUpTo: $:.
  	].
  
  	page := bare copyFrom: (bare indexOf: $/) to: bare size.
  	page size = 0 ifTrue: [page := '/'].
  	(self shouldUseProxy: serverName) ifTrue: [ 
  		page := 'http://', serverName, ':', port printString, page.		"put back together"
  		serverName := self httpProxyServer.
  		port := self httpProxyPort].
  
    	"make the request"	
  	serverAddr := NetNameResolver addressForName: serverName timeout: 20.
  	serverAddr ifNil: [
  		^ 'Could not resolve the server named: ', serverName].
  
+ 	authorization := (user , ':' , passwd) base64Encoded.
- 	authorization := (Base64MimeConverter mimeEncode: (user , ':' , passwd) readStream) contents.
  	s := HTTPSocket new.
  	s connectTo: serverAddr port: port.
  	s waitForConnectionUntil: self standardDeadline.
  	Transcript cr; show: url; cr.
  	command := 
  		'PUT ', page, ' HTTP/1.0', CrLf, 
  		self userAgentString, CrLf,
  		'Host: ', specifiedServer, CrLf, 
  		'ACCEPT: */*', CrLf,
  		HTTPProxyCredentials,
  		'Authorization: Basic ' , authorization , CrLf , 
  		'Content-length: ', contents size printString, CrLf , CrLf , 
  		contents.
  	s sendCommand: command.
  	"get the header of the reply"
  	list := s getResponseUpTo: CrLf, CrLf ignoring: (String with: CR).	"list = header, CrLf, CrLf, beginningOfData"
  	header := list at: 1.
  	"Transcript show: page; cr; show: argsStream contents; cr; show: header; cr."
  	firstData := list at: 3.
  
  	"dig out some headers"
  	s header: header.
  	length := s getHeader: 'content-length'.
  	length ifNotNil: [ length := length asNumber ].
  
  	aStream := s getRestOfBuffer: firstData totalLength: length.
  	s destroy.	"Always OK to destroy!!"
  
  	^ header, aStream contents!

Item was changed:
  OldSimpleClientSocket subclass: #HTTPSocket
  	instanceVariableNames: 'headerTokens headers responseCode'
+ 	classVariableNames: 'HTTPBlabEmail HTTPPort HTTPProxyCredentials HTTPProxyExceptions LogToTranscript ParamDelimiters'
- 	classVariableNames: 'LogToTranscript HTTPProxyCredentials HTTPPort HTTPBlabEmail ParamDelimiters HTTPProxyExceptions'
  	poolDictionaries: ''
  	category: 'Network-Protocols'!
  
  !HTTPSocket commentStamp: '<historical>' prior: 0!
  HTTPSockets support HTTP requests, either directly or via an HTTP proxy server. An HTTPSocket saves the parse of the last ASCII header it saw, to avoid having to parse it repeatedly.
  
  The real action is in httpGet:accept:.  See the examples in the class, especially httpFileInNewChangeSet: and httpShowGif:.!

Item was changed:
  Object subclass: #OldSocket
  	instanceVariableNames: 'semaphore socketHandle readSemaphore writeSemaphore primitiveOnlySupportsOneSemaphore'
+ 	classVariableNames: 'Connected DeadServer InvalidSocket OtherEndClosed Registry RegistryThreshold TCPSocketType ThisEndClosed UDPSocketType Unconnected WaitingForConnection'
- 	classVariableNames: 'InvalidSocket ThisEndClosed WaitingForConnection UDPSocketType Registry TCPSocketType OtherEndClosed Connected Unconnected RegistryThreshold DeadServer'
  	poolDictionaries: ''
  	category: 'Network-Kernel'!
  
  !OldSocket commentStamp: '<historical>' prior: 0!
  A Socket represents a network connection point. Current sockets are designed to support the TCP/IP and UDP protocols
  
  Subclasses of socket provide support for network protocols such as POP, NNTP, HTTP, and FTP. Sockets also allow you to implement your own custom services and may be used to support Remote Procedure Call or Remote Method Invocation some day.
  
  JMM June 2nd 2000 Macintosh UDP support was added if you run open transport.
  !

Item was changed:
  Object subclass: #NetNameResolver
  	instanceVariableNames: ''
+ 	classVariableNames: 'DefaultHostName HaveNetwork ResolverBusy ResolverError ResolverMutex ResolverReady ResolverSemaphore ResolverUninitialized'
- 	classVariableNames: 'ResolverReady DefaultHostName ResolverUninitialized ResolverMutex ResolverSemaphore ResolverError ResolverBusy HaveNetwork'
  	poolDictionaries: ''
  	category: 'Network-Kernel'!
  
  !NetNameResolver commentStamp: '<historical>' prior: 0!
  This class implements TCP/IP style network name lookup and translation facilities.
  
  Attempt to keep track of whether there is a network available.
  HaveNetwork	true if last attempt to contact the network was successful.
  LastContact		Time of that contact (totalSeconds).
  haveNetwork	returns true, false, or #expired.  True means there was contact in the last 30 minutes.  False means contact failed or was false last time we asked.  Get out of false state by making contact with a server in some way (FileList or updates).!

Item was changed:
  OldSocket subclass: #OldSimpleClientSocket
  	instanceVariableNames: 'buffer bufferPos'
+ 	classVariableNames: 'CR CrLf LF'
- 	classVariableNames: 'CrLf LF CR'
  	poolDictionaries: ''
  	category: 'Network-Kernel'!
  
  !OldSimpleClientSocket commentStamp: '<historical>' prior: 0!
  This class supports client for simple network protocols based on sending textual commands and responses. Examples of such protocols include POP3 (mail retrieval), SMTP (mail posting), HTTP (web browsing), and NTTP (network news). Some simple examples are presented as class methods, but a full-service client of some service should be implemented as a subclass.
  
  The basic services provided by this class are:
  	sendCommand:			-- sends a command line terminate with <CR><LF>
  	getResponse				-- gets a single-line response to a command
  	getMultilineResponse	-- gets a multiple line response terminated by a period
  							-- on a line by itself
  
  There are variants of the getResponse commands that display lines on the screen as they are being received. Linefeeds are stripped out of all responses.
  
  The 'get' commands above make use of an internal buffer.  So intermixing these two commands and regular Socket recieve commands can cause problems.!

Item was changed:
  Object subclass: #Socket
  	instanceVariableNames: 'semaphore socketHandle readSemaphore writeSemaphore primitiveOnlySupportsOneSemaphore'
+ 	classVariableNames: 'Connected DeadServer InvalidSocket OtherEndClosed Registry RegistryThreshold TCPSocketType ThisEndClosed UDPSocketType Unconnected WaitingForConnection'
- 	classVariableNames: 'InvalidSocket ThisEndClosed WaitingForConnection UDPSocketType Registry Unconnected Connected OtherEndClosed TCPSocketType RegistryThreshold DeadServer'
  	poolDictionaries: ''
  	category: 'Network-Kernel'!
  
  !Socket commentStamp: 'gk 12/13/2005 00:43' prior: 0!
  A Socket represents a network connection point. Current sockets are designed to support the TCP/IP and UDP protocols. Sockets are the lowest level of networking object in Squeak and are not normally used directly. SocketStream is a higher level object wrapping a Socket in a stream like protocol.
  
  ProtocolClient and subclasses are in turn wrappers around a SocketStream to provide support for specific network protocols such as POP, NNTP, HTTP, and FTP.!




More information about the Squeak-dev mailing list