MCHttpRepository.st
branchjv
changeset 989 4589c38afe55
parent 909 b63cf5148da4
equal deleted inserted replaced
988:536fd853efeb 989:4589c38afe55
     1 "{ Package: 'stx:goodies/monticello' }"
     1 "{ Package: 'stx:goodies/monticello' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
     2 
     4 
     3 MCFileBasedRepository subclass:#MCHttpRepository
     5 MCFileBasedRepository subclass:#MCHttpRepository
     4 	instanceVariableNames:'location user password readerCache'
     6 	instanceVariableNames:'location user password readerCache'
     5 	classVariableNames:''
     7 	classVariableNames:''
     6 	poolDictionaries:''
     8 	poolDictionaries:''
   216 
   218 
   217     "Modified: / 14-09-2010 / 19:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   219     "Modified: / 14-09-2010 / 19:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   218 !
   220 !
   219 
   221 
   220 writeStreamForFileNamed: aString replace: ignoreBoolean do: aBlock
   222 writeStreamForFileNamed: aString replace: ignoreBoolean do: aBlock
   221 	| stream response |
   223         | stream response |
   222 	stream := RWBinaryOrTextStream on: String new.
   224         stream := RWBinaryOrTextStream on: String new.
   223 	aBlock value: stream.
   225         aBlock value: stream.
   224 	response := HTTPSocket
   226 "/        response := HTTPSocket
   225 					httpPut: stream contents
   227 "/                                        httpPut: stream contents
   226 					to: (self urlForFileNamed: aString)
   228 "/                                        to: (self urlForFileNamed: aString)
   227 					user: self user
   229 "/                                        user: self user
   228 					passwd: self password.
   230 "/                                        passwd: self password.
   229 
   231         response := HTTPInterface
   230 	(#( 'HTTP/1.1 201 ' 'HTTP/1.1 200 ' 'HTTP/1.0 201 ' 'HTTP/1.0 200 ')
   232                         request:#PUT
   231 		anySatisfy: [:code | response beginsWith: code ])
   233                         url:(self urlForFileNamed: aString)
   232 			ifFalse: [self error: response].
   234                         fromHost:nil port:nil
       
   235                         accept:#('*/*')
       
   236                         fromDocument:nil
       
   237                         userName:self user password: self password 
       
   238                         contentType:'application/octet-stream'
       
   239                         contents:stream contents asString.
       
   240 
       
   241         (#( 201 200 ) includes: response responseCode) ifFalse: [self error: response].
       
   242 
       
   243     "Modified: / 24-04-2015 / 00:12:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   233 ! !
   244 ! !
   234 
   245 
   235 !MCHttpRepository class methodsFor:'documentation'!
   246 !MCHttpRepository class methodsFor:'documentation'!
   236 
   247 
   237 version
   248 version
   240 
   251 
   241 version_CVS
   252 version_CVS
   242     ^ '$Header: /cvs/stx/stx/goodies/monticello/MCHttpRepository.st,v 1.7 2014-02-12 14:53:40 cg Exp $'
   253     ^ '$Header: /cvs/stx/stx/goodies/monticello/MCHttpRepository.st,v 1.7 2014-02-12 14:53:40 cg Exp $'
   243 !
   254 !
   244 
   255 
       
   256 version_HG
       
   257 
       
   258     ^ '$Changeset: <not expanded> $'
       
   259 !
       
   260 
   245 version_SVN
   261 version_SVN
   246     ^ '$Id: MCHttpRepository.st,v 1.7 2014-02-12 14:53:40 cg Exp $'
   262     ^ '$Id: MCHttpRepository.st,v 1.7 2014-02-12 14:53:40 cg Exp $'
   247 ! !
   263 ! !
   248 
   264