The Trunk: Monticello-ar.397.mcz

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

The Trunk: Monticello-ar.397.mcz

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

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

Name: Monticello-ar.397
Author: ar
Time: 21 July 2010, 8:12:14.706 pm
UUID: 4b8f347f-bae6-d44b-96e2-f03278aa6bd2
Ancestors: Monticello-eem.396

More robust handling of HTTP upload responses. WebDAV for example returns a 204 (no content) after an upload. Enumerating all possible responses of the server really isn't going to cut it, so parse the response instead.

=============== Diff against Monticello-eem.396 ===============

Item was changed:
  ----- Method: MCHttpRepository>>writeStreamForFileNamed:replace:do: (in category 'required') -----
  writeStreamForFileNamed: aString replace: ignoreBoolean do: aBlock
+ | stream response statusLine code |
- | stream response |
  stream := RWBinaryOrTextStream on: String new.
  aBlock value: stream.
  self displayProgress: 'Uploading ', aString during:[
  response := HTTPSocket
  httpPut: stream contents
  to: (self urlForFileNamed: aString)
  user: self user
  passwd: self password.
  ].
+ "More robust handling of HTTP responses. Instead of enumerating
+ all possible return codes and http versions, do a quick parse"
+ (response beginsWith: 'HTTP/') ifTrue:[
+ "Looks like an HTTP header, not some error message"
+ statusLine := response copyUpTo: Character cr.
+ code := [(statusLine findTokens: ' ') second asInteger] on: Error do:[].
+ ].
+ (code isInteger and:[code between: 200 and: 299])
+ ifFalse:[self error: response].!
- (#( 'HTTP/1.1 201 ' 'HTTP/1.1 200 ' 'HTTP/1.0 201 ' 'HTTP/1.0 200 ')
- anySatisfy: [:code | response beginsWith: code ])
- ifFalse: [self error: response].!