The Trunk: Network-ar.89.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Network-ar.89.mcz

commits-2
Andreas Raab uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-ar.89.mcz

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

Name: Network-ar.89
Author: ar
Time: 5 September 2010, 11:18:04.594 am
UUID: d7b83263-24a1-1b4f-b5a6-4af1ab6b5fc3
Ancestors: Network-ar.88

Restructurings to reduce package depencencies.

=============== Diff against Network-ar.88 ===============

Item was added:
+ ----- Method: FileStream class>>httpPostMultipart:args: (in category '*network') -----
+ httpPostMultipart: url args: argsDict
+ | mimeBorder argsStream crLf resultStream result |
+ " do multipart/form-data encoding rather than x-www-urlencoded "
+
+ crLf := String crlf.
+ mimeBorder := '----squeak-', Time millisecondClockValue printString, '-stuff-----'.
+ "encode the arguments dictionary"
+ argsStream := WriteStream on: String new.
+ argsDict associationsDo: [:assoc |
+ assoc value do: [ :value | | fieldValue |
+ "print the boundary"
+ argsStream nextPutAll: '--', mimeBorder, crLf.
+ " check if it's a non-text field "
+ argsStream nextPutAll: 'Content-disposition: form-data; name="', assoc key, '"'.
+ (value isKindOf: MIMEDocument)
+ ifFalse: [fieldValue := value]
+ ifTrue: [argsStream nextPutAll: ' filename="', value url pathForFile, '"', crLf, 'Content-Type: ', value contentType.
+ fieldValue := (value content
+ ifNil: [(FileStream fileNamed: value url pathForFile) contentsOfEntireFile]
+ ifNotNil: [value content]) asString].
+ " Transcript show: 'field=', key, '; value=', fieldValue; cr. "
+ argsStream nextPutAll: crLf, crLf, fieldValue, crLf.
+ ]].
+ argsStream nextPutAll: '--', mimeBorder, '--'.
+
+ resultStream := self
+ post:
+ ('Content-type: multipart/form-data; boundary=', mimeBorder, crLf,
+ 'Content-length: ', argsStream contents size printString, crLf, crLf,
+ argsStream contents)
+ url: url ifError: [^'Error in post ' url asString].
+ "get the header of the reply"
+ result := resultStream upToEnd.
+ ^MIMEDocument content: result!

Item was added:
+ ----- Method: ImageReadWriter class>>formFromServerFile: (in category '*network') -----
+ formFromServerFile: fileName
+ "Answer a ColorForm stored on the file with the given name.  Meant to be called from during the getting of updates from the server.  That assures that (Utilities serverUrls) returns the right group of servers."
+
+ | urls |
+ urls := Utilities serverUrls collect:
+ [:url | url, fileName].  " fileName starts with: 'updates/'  "
+ urls do: [:aURL | | form doc |
+ (fileName findTokens: '.') last asLowercase = 'gif' ifTrue: [
+ form := HTTPSocket httpGif: aURL.
+ form = (ColorForm extent: 20@20 depth: 8)
+ ifTrue: [self inform: 'The file ',aURL,' is ill formed.'].
+ ^ form].
+ (fileName findTokens: '.') last asLowercase = 'bmp' ifTrue: [
+ doc := HTTPSocket httpGet: aURL accept: 'image/bmp'.
+ form := Form fromBMPFile: doc.
+ doc close.
+ form ifNil: [self inform: 'The file ',aURL,' is ill formed.'. ^ Form new]
+ ifNotNil: [^ form]].
+ self inform: 'File ', fileName, 'does not end with .gif or .bmp'].
+ self inform: 'That file not found on any server we know'.!

Item was added:
+ ----- Method: FileStream class>>httpPostDocument:args: (in category '*network') -----
+ httpPostDocument: url args: argsDict
+ | argString |
+ argString := argsDict
+ ifNotNil: [argString := HTTPSocket argString: argsDict]
+ ifNil: [''].
+ ^self post: argString url: url , argString ifError: [self halt]!

Item was added:
+ ----- Method: FileStream class>>requestURLStream:ifError: (in category '*network') -----
+ requestURLStream: url ifError: errorBlock
+ "FileStream requestURLStream:'http://isgwww.cs.uni-magdeburg.de/~raab'"
+ ^self concreteStream new requestURLStream: url ifError: errorBlock!

Item was added:
+ ----- Method: FileStream class>>requestURLStream: (in category '*network') -----
+ requestURLStream: url
+ "FileStream requestURLStream:'http://isgwww.cs.uni-magdeburg.de/~raab'"
+ ^self concreteStream new requestURLStream: url!

Item was added:
+ ----- Method: FileStream class>>post:url:ifError: (in category '*network') -----
+ post: data url: url ifError: errorBlock
+ ^self post: data target: nil url: url ifError: errorBlock!

Item was added:
+ ----- Method: FileStream class>>requestURL:target: (in category '*network') -----
+ requestURL: url target: target
+ "FileStream requestURL:'http://isgwww.cs.uni-magdeburg.de/~raab' target: ':=blank' "
+ ^self concreteStream new requestURL: url target: target!

Item was added:
+ ----- Method: FileStream class>>post:target:url:ifError: (in category '*network') -----
+ post: data target: target url: url ifError: errorBlock
+ ^self concreteStream new post: data target: target url: url ifError: errorBlock!