SystemOrganization addCategory: #'Curl-Core'! SystemOrganization addCategory: #'Curl-Tests'! Object subclass: #Curl instanceVariableNames: 'handle url idleBlock multiMode' classVariableNames: '' poolDictionaries: '' category: 'Curl-Core'! !Curl commentStamp: 'dao 8/26/2007 22:15' prior: 0! User Interface to the libcurl 'easy' handle. (Curl new onVerbose; getContentsUrl: 'http://www.squeak.org/') (Curl new getContentsUrl: 'ftp://ftp.squeak.org/docs/OOPSLA.Squeak.html') (Curl new getContentsUrl: 'tftp://127.0.0.1/TFTPD32.HLP') (Curl new proxy: '192.11.224.124:8000'; getContentsUrl: 'http://www.squeak.org/') (Curl new caInfo: 'c:\danil\squeak\cacert.pem'; "offSSLVerifyPeer;" getContentsUrl: 'https://www.google.com/index.html') "problems? see this http://curl.haxx.se/docs/sslcerts.html" (Curl new getContentsUrl: 'file://e:\squeak\ReadMe.txt') openInWorkspaceWithTitle: 'Reame.txt' (Curl new getContentsUrl: 'ftp://ftp.squeak.org/docs/OOPSLA.Squeak.html' putContentsUrl: 'file://e:\test.html') (Curl new getContentsUrl: 'http://www.squeak.org/' putUrl: 'ftp://127.0.0.1/Upload/index.html') (Curl new getContentsUrl: 'file://e:\squeak\ReadMe.txt' putContentsUrl: 'ftp://127.0.0.1/Upload/index.html') (Curl new getContentsUrl: 'file://e:\squeak\ReadMe.txt' putContentsUrl: 'file://e:\ASDF\ReadMe.txt' ) (Curl new getContentsUrl: 'file://e:\squeak\ReadMe.txt' putContentsUrl: 'http://127.0.0.1/ReadMe.txt' ) (Curl new getContentsUrl: 'file://e:\ASD\ReadMe.txt' ) "fetch one file 100 times" (1 to: 100) inject: Curl new into: [:curl :i | curl getContentsUrl: 'ftp://127.0.0.1/Lang/vip-license.txt'; yourself] (1 to: 100) inject: Curl new into: [:curl :i | curl getContentsUrl: 'file://e:\squeak\ReadMe.txt'; yourself] (Curl new onVerbose; getContentsUrl: 'scp://danil:xxxx@127.0.0.1/home/danil/.bash_history' ) ! !Curl class methodsFor: 'api global' stamp: 'dao 8/26/2007 18:38'! curlVersion ^self primitiveFailedInvalidCurlHandle! ! !Curl class methodsFor: 'examples' stamp: 'dao 10/1/2006 12:47'! exampleIdleBlock "self exampleIdleBlock" | button curl | button := ScriptableButton new. curl := Curl new idleBlock: [:c | button label: (c dataSize printString , ' of ' , c url , ' downloaded, press me to cancel')]; yourself. button actionSelector: #cancel; target: curl; openInHand. [curl getContentsUrl: 'http://ftp.squeak.org/sources_files/SqueakV3.sources.gz' putContentsUrl: 'file://e:\SqueakV3.sources.gz'. WorldState addDeferredUIMessage: [button delete] ] forkAt: Processor userBackgroundPriority ! ! !Curl class methodsFor: 'examples' stamp: 'dao 10/1/2006 23:11'! exampleIdleBlockLocal "self exampleIdleBlockLocal" | button curl | button := ScriptableButton new. curl := Curl new idleBlock: [:c | button label: (c dataSize printString , ' of ' , c url , ' downloaded, press me to cancel')]; yourself. button actionSelector: #cancel; target: curl; openInHand. [curl getContentsUrl: 'ftp://127.0.0.1/VMWare/kubuntu-6.06-desktop-i386.iso' putContentsUrl: 'file://e:\deleteMe.dat'. WorldState addDeferredUIMessage: [button delete] ] forkAt: Processor userBackgroundPriority ! ! !Curl class methodsFor: 'examples' stamp: 'dao 10/1/2006 12:46'! exampleParallelDownloads "self exampleParallelDownloads" 1 to: 4 do: [:i | [ | c | c := (Curl new getContentsUrl: 'http://minnow.cc.gatech.edu/squeak/' , i printString). WorldState addDeferredUIMessage: [ c openInWorkspaceWithTitle: ('http://minnow.cc.gatech.edu/squeak/' , i printString )]] fixTemps forkAt: Processor userBackgroundPriority ]! ! !Curl class methodsFor: 'examples' stamp: 'dao 10/1/2006 12:46'! exampleReuseHandle "self exampleReuseHandle" [(1 to: 4) inject: Curl new into: [:curl :i || url c | url := 'http://minnow.cc.gatech.edu/squeak/' , i printString. c := curl getContentsUrl: url. WorldState addDeferredUIMessage: [c openInWorkspaceWithTitle: url]. curl ] ]forkAt: Processor userBackgroundPriority ! ! !Curl class methodsFor: 'pvt handles-mgmt' stamp: 'dao 10/1/2006 16:28'! finalizeHandle: aLargeIntegerCurlHandle aLargeIntegerCurlHandle ifNotNil: [ self pFreeCurlHandle: aLargeIntegerCurlHandle ]! ! !Curl class methodsFor: 'pvt handles-mgmt' stamp: 'dao 10/1/2006 16:28'! newHandle " *PRIVATE* don't use it use 'Curl new' to get new curl handle " ^self pNewCurlHandle! ! !Curl class methodsFor: 'prim handles-mgmt' stamp: 'dao 10/1/2006 16:23'! pFreeCurlHandle: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl class methodsFor: 'prim handles-mgmt' stamp: 'dao 10/1/2006 16:29'! pNewCurlHandle ^self primitiveFailed! ! !Curl class methodsFor: 'debugging' stamp: 'dao 10/1/2006 16:23'! pNumberOfMemChunks ^self primitiveFailedInvalidCurlHandle! ! !Curl class methodsFor: 'prim global' stamp: 'dao 8/26/2007 17:45'! pTimeFromString: aString ^self primitiveFailedInvalidCurlHandle ! ! !Curl class methodsFor: 'api global' stamp: 'dao 8/26/2007 17:48'! timeFromString: aString | secondsFromUnixEpoch | secondsFromUnixEpoch := self pTimeFromString: aString. secondsFromUnixEpoch = -1 ifTrue: [self error: 'Invalid date/time format'.]. ^(DateAndTime year: 1970 day: 1) + (Duration seconds: secondsFromUnixEpoch) ! ! !Curl methodsFor: 'user api - http options' stamp: 'gc 9/26/2007 23:45'! addHeader: aString self pList: handle Append: aString! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 10/13/2006 13:06'! args: aDictionary "make an args string ready for appending to the url" ^ String streamContents: [:s | s nextPut: $?. aDictionary associationsDo: [:a | s nextPutAll: (self escape: a key). s nextPut: $=. s nextPutAll: (self escape: a value). s nextPut: $&]. s position isZero ifFalse: [ s skip: -1 ]] ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/8/2006 19:26'! caInfo: aString "platform specific filename for certificates" self pEasy: handle CaInfo: aString. self checkEasyStatus. ^self! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 10/1/2006 16:36'! cancel "cancel current transfer - clear buffers" self multiDettach; clearContents ! ! !Curl methodsFor: 'error info' stamp: 'dao 9/14/2006 18:13'! checkEasyStatus self easyStatus = 0 ifFalse: [self error: self easyStatusString]! ! !Curl methodsFor: 'error info' stamp: 'dao 10/1/2006 22:42'! checkMultiStatus (self multiStatus = 0 or: [self multiStatus =-1]) ifFalse: [self error: self multiStatusString]! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 10/1/2006 16:36'! clearContents self pEmptyBuffers: handle! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 9/10/2006 19:25'! contents "get contents of the internal plugin buffers, - return aByteString " ^self fetchBuffersContentsAtOnce "new faster one" "^self fetchBuffersContentsOneByOne "" old - proven one"! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 10/1/2006 16:36'! contents: aByteString "place aByteString into internal plugin buffer for upload if there is old content - delete it" ^self pSet: handle BuffersData: aByteString! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 8/26/2007 19:17'! cookie: aString ". It will be used to set a cookie in the http request. The format of the string should be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain. If you need to set multiple cookies, you need to set them all using a single option and thus you need to concatenate them all in one single string. Set multiple cookies in one string like this: 'name1=content1; name2=content2;'' etc. Using this option multiple times will only make the latest string override the previously ones. " self pEasy: handle Cookie: aString. self checkEasyStatus. ^self! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 8/26/2007 19:17'! cookieFile: aString " It should contain the name of your file holding cookie data to read. The cookie data may be in Netscape / Mozilla cookie data format or just regular HTTP-style headers dumped to a file. Given an empty or non-existing file or by passing the empty string (""), this option will enable cookies for this curl handle, making it understand and parse received cookies and then use matching cookies in future request. If you use this option multiple times, you just add more files to read. Subsequent files will add more cookies." self pEasy: handle CookieFile: aString. self checkEasyStatus. ^self! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 8/26/2007 19:18'! cookieJar: aString "Pass a file name as char *, zero terminated. This will make libcurl write all internally known cookies to the specified file when curl_easy_cleanup(3) is called. If no cookies are known, no file will be created. Specify - to instead have the cookies written to stdout. Using this option also enables cookies for this session, so if you for example follow a location it will make matching cookies get sent accordingly. If the cookie jar file can't be created or written to (when the curl_easy_cleanup(3) is called), libcurl will not and cannot report an error for this. Using CURLOPT_VERBOSE or CURLOPT_DEBUGFUNCTION will get a warning to display, but that is the only visible feedback you get about this possibly lethal situation." self pEasy: handle CookieJar: aString. self checkEasyStatus. ^self! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 8/26/2007 19:19'! cookieSession " It will force libcurl to ignore all cookies it is about to load that are 'session cookies' from the previous session. By default, libcurl always stores and loads all cookies, independent if they are session cookies are not. Session cookies are cookies without expiry date and they are meant to be alive and existing for this 'session' only." ^self pEasy: handle CookieSession: 1 ! ! !Curl methodsFor: 'user api - curl version' stamp: 'dao 3/23/2007 17:57'! curlVersion ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'accessing - buffer info' stamp: 'dao 9/7/2006 11:53'! dataSize "for curious - return current data size in the plugin buffer chain" ^self pDataSize: handle! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/8/2006 19:31'! defaultCaInfo self caInfo: self defaultCaInfoFilename ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/8/2006 19:30'! defaultCaInfoFilename ^FileDirectory default fullNameFor: 'CurlPluginCaCert.pem'! ! !Curl methodsFor: 'user api - basic' stamp: 'gc 10/29/2007 08:37'! delete "delete the url (that should be set). raise walkback on errors. " ^self onDelete; checkEasyStatus; perform; checkEasyStatus; readRewind! ! !Curl methodsFor: 'initialize-release' stamp: 'dao 10/1/2006 17:28'! destroy "free resources - handle will be unusable" self class finalizeHandle: handle. handle := nil.! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 10/8/2006 17:22'! download "download contents of the url into the plugin buffer (url should be set allready). old buffer contents will be lost. raise walkback on errors. " ^self offUpload; checkEasyStatus; onHttpGet; checkEasyStatus; perform; checkEasyStatus! ! !Curl methodsFor: 'pvt easy-perform' stamp: 'dao 10/1/2006 16:37'! easyPerform "call curl_easy_perform to start transfer, call is blocking, curl_easy handle should be fully configured for transfer, store int return status" self pEasyPerform: handle! ! !Curl methodsFor: 'pvt easy-perform' stamp: 'dao 10/1/2006 16:37'! easyStatus ^self pEasyStatus: handle.! ! !Curl methodsFor: 'error info' stamp: 'dao 10/1/2006 16:37'! easyStatusString "call libcurl to descript the status code" ^self pEasyStrError: handle.! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 10/13/2006 11:57'! escape: aString ^self pEasy: handle Escape: aString ! ! !Curl methodsFor: 'pvt perform' stamp: 'dao 10/1/2006 16:37'! fetchBuffersContentsAtOnce "get plugin buffer at once - plugin side joins all sub-buffers togather. return aByteString empty the buffer " ^self pFetchBuffers: handle. ! ! !Curl methodsFor: 'pvt perform' stamp: 'dao 10/1/2006 16:37'! fetchBuffersContentsOneByOne "get all plugin sub-buffers and join them in one chunk. return aByteString" | data stream | data := self fetchNextBuffer. data ifNil: [^nil "XXX - what to do, it there is no data?"]. "ok, at least one buffer found, create stream and append all buffers to it" stream := RWBinaryOrTextStream with: data. [ (data := self fetchNextBuffer) notNil] whileTrue: [ stream nextPutAll: data ]. ^stream contents! ! !Curl methodsFor: 'pvt perform' stamp: 'dao 10/1/2006 16:37'! fetchNextBuffer "buffer refers to the chank where libcurl writes data during transfer. Return the content of the next sub-buffer. Free buffer on the plugin side." ^self pFetchNextBuffer: handle! ! !Curl methodsFor: 'user api' stamp: 'dao 10/1/2006 12:46'! getContents " return contents of the url as a ByteString. Free plugin buffer" | s | s := self download; contents. self clearContents. ^s! ! !Curl methodsFor: 'user api' stamp: 'dao 10/1/2006 12:46'! getContentsUrl: aString " return contents of the url as a ByteString. Free plugin buffer" ^self url: aString; getContents.! ! !Curl methodsFor: 'user api' stamp: 'dao 10/1/2006 12:47'! getContentsUrl: aStringSrc putContentsUrl: aStringDst "copy data between src and dst url. free plugin buffer" self url: aStringSrc; download; url: aStringDst; upload; clearContents! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 8/26/2007 19:21'! httpNotSupportedYet " CURLOPT_ENCODING CURLOPT_UNRESTRICTED_AUTH CURLOPT_POSTFIELDS CURLOPT_POSTFIELDSIZE CURLOPT_POSTFIELDSIZE_LARGE CURLOPT_HTTPPOST CURLOPT_POSTFIELDS CURLOPT_POSTFIELDSIZE CURLOPT_POSTFIELDSIZE_LARGE CURLOPT_USERAGENT CURLOPT_HTTPHEADER CURLOPT_HTTP200ALIASES CURLOPT_COOKIELIST CURLOPT_HTTP_VERSION CURLOPT_HTTP_CONTENT_DECODING CURLOPT_HTTP_TRANSFER_DECODING CURLOPT_IGNORE_CONTENT_LENGTH "! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 9/13/2006 15:24'! idleBlock: aBlock idleBlock := aBlock! ! !Curl methodsFor: 'user api - info time' stamp: 'dao 10/1/2006 16:37'! infoConnectTime ^Duration seconds: (self pInfoConnectTime: handle) rounded! ! !Curl methodsFor: 'user api - info ' stamp: 'dao 10/1/2006 16:37'! infoContentLengthDownload ^(self pInfoContentLengthDownload: handle) asInteger! ! !Curl methodsFor: 'user api - info ' stamp: 'dao 10/1/2006 16:37'! infoContentLengthUpload ^(self pInfoContentLengthUpload: handle) asInteger! ! !Curl methodsFor: 'user api - info strings' stamp: 'dao 10/1/2006 16:38'! infoContentType ^self pInfoContentType: handle! ! !Curl methodsFor: 'user api - info strings' stamp: 'dao 10/1/2006 16:38'! infoEffectiveUrl ^self pInfoEffectiveUrl: handle! ! !Curl methodsFor: 'user api - info ' stamp: 'dao 10/1/2006 18:47'! infoFileTime | secondsFromUnixEpoch | secondsFromUnixEpoch := self pInfoFileTime: handle. (secondsFromUnixEpoch = -1) ifTrue: [^nil "libcurl has no clue about time of a file"]. ^(DateAndTime year: 1970 day: 1) + (Duration seconds: secondsFromUnixEpoch) ! ! !Curl methodsFor: 'user api - info strings' stamp: 'dao 10/1/2006 16:38'! infoFtpEntryPath ^self pInfoFtpEntryPath: handle! ! !Curl methodsFor: 'user api - info time' stamp: 'dao 10/1/2006 16:38'! infoNameLookupTime ^Duration seconds: (self pInfoNameLookupTime: handle) rounded! ! !Curl methodsFor: 'user api - info time' stamp: 'dao 10/1/2006 16:38'! infoPreTransferTime ^Duration seconds: (self pInfoPreTransferTime: handle) rounded! ! !Curl methodsFor: 'user api - info strings' stamp: 'dao 10/1/2006 16:38'! infoPrivate ^self pInfoPrivate: handle! ! !Curl methodsFor: 'user api - info time' stamp: 'dao 10/1/2006 16:38'! infoRedirectTime ^Duration seconds: (self pInfoRedirectTime: handle) rounded! ! !Curl methodsFor: 'user api - info ' stamp: 'dao 10/1/2006 16:38'! infoResponseCode ^self pInfoResponseCode: handle! ! !Curl methodsFor: 'user api - info ' stamp: 'dao 10/1/2006 16:39'! infoSizeDownload ^(self pInfoSizeDownload: handle) asInteger! ! !Curl methodsFor: 'user api - info ' stamp: 'dao 10/1/2006 16:39'! infoSizeUpload ^(self pInfoSizeUpload: handle) asInteger! ! !Curl methodsFor: 'user api - info ' stamp: 'dao 10/1/2006 16:39'! infoSpeedDownload ^(self pInfoSpeedDownload: handle) asInteger! ! !Curl methodsFor: 'user api - info ' stamp: 'dao 10/1/2006 16:39'! infoSpeedUpload ^(self pInfoSpeedUpload: handle) asInteger! ! !Curl methodsFor: 'user api - info time' stamp: 'dao 10/1/2006 16:39'! infoStartTransferTime ^Duration seconds: (self pInfoStartTransferTime: handle) rounded! ! !Curl methodsFor: 'user api - info time' stamp: 'dao 10/1/2006 16:39'! infoTotalTime ^Duration seconds: (self pInfoTotalTime: handle) rounded! ! !Curl methodsFor: 'initialize-release' stamp: 'dao 10/1/2006 13:42'! initialize handle := self class newHandle. idleBlock := [:c | Processor yield]. self toFinalizeSend: #finalizeHandle: to: self class with: handle. multiMode := false.! ! !Curl methodsFor: 'pvt multi-perform' stamp: 'dao 10/1/2006 16:39'! isMultiRunning ^self pIsMultiRunning: handle! ! !Curl methodsFor: 'pvt multi-perform' stamp: 'dao 10/7/2006 19:39'! maxIdleDelayMilliseconds ^100! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 8/26/2007 19:14'! maxRedirs: anInteger "The set number will be the redirection limit. If that many redirections have been followed, the next redirect will cause an error " ^self pEasy: handle MaxRedirs: anInteger ! ! !Curl methodsFor: 'pvt multi-perform' stamp: 'dao 10/1/2006 16:39'! multiAttach multiMode ifTrue: [^self]. self pMultiAttach: handle; checkMultiStatus. multiMode := true. ^self ! ! !Curl methodsFor: 'pvt multi-perform' stamp: 'dao 10/1/2006 16:40'! multiDettach multiMode ifFalse: [^self]. self pMultiDetach: handle. "dont check status because it can be already dtached: checkMultiStatus". multiMode := false. ^self! ! !Curl methodsFor: 'pvt multi-perform' stamp: 'dao 10/1/2006 23:01'! multiPerform "call curl_multi_perform to start transfer, call is non-blocking, curl_easy handle should be fully configured for transfer, store int return status" ^self multiPerformSparse! ! !Curl methodsFor: 'pvt multi-perform' stamp: 'dao 10/1/2006 22:53'! multiPerformDense "this version will poll at first opportunity resulting in fastest transfers and high CPU load " self multiAttach. [self pMultiPerform: handle; checkMultiStatus. self isMultiRunning] whileTrue: [ idleBlock value: self]. self pMultiInfoRead: handle. self multiDettach. ^self! ! !Curl methodsFor: 'pvt multi-perform' stamp: 'dao 10/8/2006 19:41'! multiPerformSparse " this version uses adaptive delays for the relief of CPU on slow transfers" | msDelay dataRead | self multiAttach. msDelay := 0. dataRead := 0. [self pMultiPerform: handle; checkMultiStatus. self isMultiRunning] whileTrue: [ msDelay > 0 ifTrue: [(Delay forMilliseconds: msDelay) wait]. dataRead < self dataSize "libcurl has got new data while we were sitting on delay" ifTrue: "then we will decrease delay" [ msDelay := (msDelay * 3 / 4) floor. ] ifFalse: "if not - increase delay" [msDelay = 0 ifTrue: [msDelay := 1] ifFalse: [msDelay := (msDelay * 5 / 4) ceiling min: self maxIdleDelayMilliseconds]]. dataRead := self dataSize. idleBlock value: self]. self pMultiInfoRead: handle. self multiDettach. ^self! ! !Curl methodsFor: 'pvt multi-perform' stamp: 'dao 10/1/2006 16:40'! multiStatus ^self pMultiStatus: handle.! ! !Curl methodsFor: 'error info' stamp: 'dao 10/1/2006 16:40'! multiStatusString "call libcurl to descript the status code" ^self pMultiStrError: handle.! ! !Curl methodsFor: 'accessing - buffer info' stamp: 'dao 9/7/2006 11:54'! numOfBuf "for curious - return current number of subbuffers in the plugin buffer chain " ^self pNumberOfBuf: handle! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 10/1/2006 16:40'! offFailOnError ^self pEasy: handle FailOnError: 0 ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/1/2006 16:40'! offFileTime ^self pEasy: handle FileTime: 0 ! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 10/1/2006 23:35'! offFollowLocation ^self pEasy: handle FollowLocation: 0 ! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 10/1/2006 16:40'! offGetHeader ^self pEasy: handle Header: 0 ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/7/2006 19:44'! offHttpProxyTunnel ^self pEasy: handle HttpProxyTunnel: 0 ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/1/2006 16:40'! offSSLVerifyPeer ^self pEasy: handle SSLVerifyPeer: 0 ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/1/2006 23:38'! offUnrestrictedAuth ^self pEasy: handle UnrestrictedAuth: 0 ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/1/2006 16:40'! offUpload ^self pEasy: handle Upload: 0 ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/1/2006 16:40'! offVerbose ^self pEasy: handle Verbose: 0 ! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 8/26/2007 19:07'! onAutoReferer "When enabled, libcurl will automatically set the Referer: field in requests where it follows a Location: redirect. " ^self pEasy: handle AutoReferer: 1 ! ! !Curl methodsFor: 'user api - switches' stamp: 'gc 10/22/2007 15:20'! onDelete ^self pEasy: handle CustomRequest: 'DELETE' ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/1/2006 16:41'! onFailOnError ^self pEasy: handle FailOnError: 1 ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/1/2006 16:41'! onFileTime ^self pEasy: handle FileTime: 1 ! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 8/26/2007 19:09'! onFollowLocation "A non-zero parameter tells the library to follow any Location: header that the server sends as part of an HTTP header. This means that the library will re-send the same request on the new location and follow new Location: headers all the way until no more such headers are returned. " ^self pEasy: handle FollowLocation: 1 ! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 10/1/2006 16:41'! onGetHeader ^self pEasy: handle Header: 1 ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 21:04'! onHttpAuthAny self pEasyHttpAuthAny: handle ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 21:04'! onHttpAuthAnySafe self pEasyHttpAuthAnySafe: handle ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 21:04'! onHttpAuthBasic self pEasyHttpAuthBasic: handle ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 21:04'! onHttpAuthDigest self pEasyHttpAuthDigest: handle ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 21:04'! onHttpAuthNtlm self pEasyHttpAuthNtlm: handle ! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 8/26/2007 19:20'! onHttpGet "this forces the HTTP request to get back to GET. usable if a POST, HEAD, PUT or a custom request have been used previously using the same curl handle. " ^self pEasy: handle HttpGet: 1 ! ! !Curl methodsFor: 'user api - http options' stamp: 'gc 9/26/2007 23:44'! onHttpHeaders ^self pEasyHttpHeaders: handle ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/7/2006 19:44'! onHttpProxyTunnel ^self pEasy: handle HttpProxyTunnel: 1 ! ! !Curl methodsFor: 'user api - http options' stamp: 'dao 8/26/2007 19:12'! onPost "A non-zero parameter tells the library to do a regular HTTP post. This will also make the library use the a Content-Type: application/x-www-form-urlencoded header. (This is by far the most commonly used POST method)." ^self pEasy: handle Post: 1 ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 21:05'! onProxyAuthAny self pEasyProxyAuthAny: handle ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 21:05'! onProxyAuthAnySafe self pEasyProxyAuthAnySafe: handle ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 21:04'! onProxyAuthBasic self pEasyProxyAuthBasic: handle ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 21:05'! onProxyAuthDigest self pEasyProxyAuthDigest: handle ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 21:05'! onProxyAuthNtlm self pEasyProxyAuthNtlm: handle ! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/1/2006 16:41'! onSSLVerifyPeer ^self pEasy: handle SSLVerifyPeer: 1 ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/1/2006 23:38'! onUnrestrictedAuth ^self pEasy: handle UnrestrictedAuth: 1 ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/1/2006 16:41'! onUpload ^self pEasy: handle Upload: 1 ! ! !Curl methodsFor: 'user api - switches' stamp: 'dao 10/1/2006 16:41'! onVerbose ^self pEasy: handle Verbose: 1 ! ! !Curl methodsFor: 'primitive buffers' stamp: 'dao 10/1/2006 16:23'! pDataSize: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/8/2006 17:39'! pEasy: aLargeIntegerCurlHandle AutoReferer: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle CaInfo: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/8/2006 17:40'! pEasy: aLargeIntegerCurlHandle Cookie: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/8/2006 17:40'! pEasy: aLargeIntegerCurlHandle CookieFile: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/8/2006 17:40'! pEasy: aLargeIntegerCurlHandle CookieJar: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/8/2006 17:40'! pEasy: aLargeIntegerCurlHandle CookieSession: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'gc 10/22/2007 15:18'! pEasy: aLargeIntegerCurlHandle CustomRequest: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle DNSCacheTimeout: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland' stamp: 'dao 10/13/2006 11:59'! pEasy: aLargeIntegerCurlHandle Escape: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle FailOnError: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle FileTime: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 23:33'! pEasy: aLargeIntegerCurlHandle FollowLocation: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle Header: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/8/2006 17:18'! pEasy: aLargeIntegerCurlHandle HttpGet: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/7/2006 19:44'! pEasy: aLargeIntegerCurlHandle HttpProxyTunnel: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/8/2006 17:43'! pEasy: aLargeIntegerCurlHandle MaxRedirs: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/8/2006 17:39'! pEasy: aLargeIntegerCurlHandle Post: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle Proxy: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 20:53'! pEasy: aLargeIntegerCurlHandle ProxyUserPwd: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle SSLVerifyPeer: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle Timeout: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland' stamp: 'dao 10/13/2006 11:59'! pEasy: aLargeIntegerCurlHandle UnEscape: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 23:38'! pEasy: aLargeIntegerCurlHandle UnrestrictedAuth: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle Upload: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle Url: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle UserPwd: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'dao 10/1/2006 16:23'! pEasy: aLargeIntegerCurlHandle Verbose: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 21:01'! pEasyHttpAuthAny: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 21:01'! pEasyHttpAuthAnySafe: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 21:00'! pEasyHttpAuthBasic: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 21:00'! pEasyHttpAuthDigest: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 21:01'! pEasyHttpAuthNtlm: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'gc 9/26/2007 23:43'! pEasyHttpHeaders: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland' stamp: 'dao 10/1/2006 16:23'! pEasyPerform: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 21:02'! pEasyProxyAuthAny: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 21:02'! pEasyProxyAuthAnySafe: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 21:02'! pEasyProxyAuthBasic: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 21:02'! pEasyProxyAuthDigest: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitives userland auth' stamp: 'dao 10/7/2006 21:02'! pEasyProxyAuthNtlm: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland' stamp: 'dao 10/1/2006 16:23'! pEasyReset: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland' stamp: 'dao 10/1/2006 16:23'! pEasyStatus: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland' stamp: 'dao 10/1/2006 16:23'! pEasyStrError: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive buffers' stamp: 'dao 10/1/2006 16:23'! pEmptyBuffers: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive buffers' stamp: 'dao 10/1/2006 16:23'! pFetchBuffers: aLargeIntegerCurlHandle "this primitive returns a ByteString contents of the plugin buffer (all sub-buffers at once) do not free buffers primitive is used for fetching the buffer contents part-by-part and concatenating it on the smalltalk side" ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive buffers' stamp: 'dao 10/1/2006 16:23'! pFetchNextBuffer: aLargeIntegerCurlHandle "this primitive returns a ByteString contents of the head sub-buffer in the plugin buffer chain. then it releases this fetched subbuffer. primitive is used for fetching the buffer contents part-by-part and concatenating it on the smalltalk side" ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-times' stamp: 'dao 10/1/2006 16:23'! pInfoConnectTime: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-doubles' stamp: 'dao 10/1/2006 16:23'! pInfoContentLengthDownload: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-doubles' stamp: 'dao 10/1/2006 16:23'! pInfoContentLengthUpload: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-strings' stamp: 'dao 10/1/2006 16:23'! pInfoContentType: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-strings' stamp: 'dao 10/1/2006 16:23'! pInfoEffectiveUrl: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-integer' stamp: 'dao 10/1/2006 16:23'! pInfoFileTime: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-strings' stamp: 'dao 10/1/2006 16:23'! pInfoFtpEntryPath: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-integer' stamp: 'dao 10/1/2006 16:23'! pInfoHTTPAuthAvail: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-integer' stamp: 'dao 10/1/2006 16:23'! pInfoHTTPConnectCode: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-integer' stamp: 'dao 10/1/2006 16:23'! pInfoHeaderSize: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-times' stamp: 'dao 10/1/2006 16:23'! pInfoNameLookupTime: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-integer' stamp: 'dao 10/1/2006 16:23'! pInfoOsErrNo: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-times' stamp: 'dao 10/1/2006 16:23'! pInfoPreTransferTime: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-strings' stamp: 'dao 10/1/2006 16:23'! pInfoPrivate: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-integer' stamp: 'dao 10/1/2006 16:23'! pInfoProxyAuthAvail: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-integer' stamp: 'dao 10/1/2006 16:23'! pInfoRedirectCount: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-times' stamp: 'dao 10/1/2006 16:23'! pInfoRedirectTime: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-integer' stamp: 'dao 10/1/2006 16:23'! pInfoRequestSize: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-integer' stamp: 'dao 10/1/2006 16:23'! pInfoResponseCode: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-integer' stamp: 'dao 10/1/2006 16:23'! pInfoSSLVerifyResult: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-doubles' stamp: 'dao 10/1/2006 16:23'! pInfoSizeDownload: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-doubles' stamp: 'dao 10/1/2006 16:23'! pInfoSizeUpload: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-doubles' stamp: 'dao 10/1/2006 16:23'! pInfoSpeedDownload: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-doubles' stamp: 'dao 10/1/2006 16:23'! pInfoSpeedUpload: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-times' stamp: 'dao 10/1/2006 16:23'! pInfoStartTransferTime: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-times' stamp: 'dao 10/1/2006 16:23'! pInfoTotalTime: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive multi' stamp: 'dao 10/1/2006 16:23'! pIsMultiRunning: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive userland options' stamp: 'gc 9/26/2007 23:45'! pList: aLargeIntegerCurlHandle Append: aString ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive multi' stamp: 'dao 10/1/2006 16:23'! pMultiAttach: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive multi' stamp: 'dao 10/1/2006 16:23'! pMultiDetach: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive multi' stamp: 'dao 10/1/2006 16:23'! pMultiInfoRead: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive multi' stamp: 'dao 10/1/2006 16:23'! pMultiPerform: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive multi' stamp: 'dao 10/1/2006 16:23'! pMultiStatus: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive multi' stamp: 'dao 10/1/2006 16:23'! pMultiStrError: anInteger ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive buffers' stamp: 'dao 10/1/2006 16:23'! pNumberOfBuf: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive buffers' stamp: 'dao 10/1/2006 16:23'! pReadRewind: aLargeIntegerCurlHandle ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive buffers' stamp: 'dao 10/1/2006 16:23'! pSet: aLargeIntegerCurlHandle BuffersData: aByteString " put aByteString into plugin buffers, delete old contents" ^self primitiveFailedInvalidCurlHandle! ! !Curl methodsFor: 'primitive easy-info-times' stamp: 'dao 3/23/2007 18:01'! pTimeFromString: aString ^self primitiveFailedInvalidCurlHandle ! ! !Curl methodsFor: 'pvt perform' stamp: 'dao 9/10/2006 18:22'! perform ^self multiPerform! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 10/7/2006 21:13'! post "http-post contents of the plugin buffers (that should be allready there by some means) to the url (that should be set). raise walkback on errors. " ^self onPost; checkEasyStatus; perform; checkEasyStatus; readRewind! ! !Curl methodsFor: 'error info' stamp: 'dao 10/1/2006 18:51'! primitiveFailedInvalidCurlHandle self error: 'a primitive has failed (invalid curl handle or parameter?)'! ! !Curl methodsFor: 'user api - options' stamp: 'dao 10/1/2006 16:41'! proxy: aString "set proxy for the next transfer" self pEasy: handle Proxy: aString. self checkEasyStatus. ^self! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/7/2006 20:52'! proxyUserPwd: aString "[ser name]:[password] to use for the connection" self pEasy: handle ProxyUserPwd: aString. self checkEasyStatus. ^self! ! !Curl methodsFor: 'user api' stamp: 'dao 10/1/2006 12:48'! putContents: aByteString "send aByteString to the configured url. free plugin buffer" ^self contents: aByteString; upload; clearContents! ! !Curl methodsFor: 'user api' stamp: 'dao 10/1/2006 12:48'! putContents: aByteString url: aString "send aByteString to the url aString. clear plugin buffer" self contents: aByteString; url: aString; upload; clearContents.! ! !Curl methodsFor: 'pvt perform' stamp: 'dao 10/1/2006 16:41'! readRewind self pReadRewind: handle! ! !Curl methodsFor: 'user api - basic' stamp: 'gc 10/26/2007 23:49'! request: aString ^self pEasy: handle CustomRequest: aString ! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 10/8/2006 17:13'! reset url := nil. self pEasyReset: handle. self clearContents.! ! !Curl methodsFor: 'user api - info time' stamp: 'dao 3/23/2007 18:31'! timeFromString: aString | secondsFromUnixEpoch | secondsFromUnixEpoch := self pTimeFromString: aString. ^(DateAndTime year: 1970 day: 1) + (Duration seconds: secondsFromUnixEpoch) ! ! !Curl methodsFor: 'user api - options' stamp: 'dao 10/1/2006 16:41'! timeout: aSmallInteger self pEasy: handle Timeout: aSmallInteger. self checkEasyStatus. ^self! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 8/26/2007 22:02'! unEscape: aString ^self pEasy: handle UnEscape: aString ! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 9/14/2006 19:06'! upload "upload contents of the plugin buffers (that should be allready there by some means) to the url (that should be set). raise walkback on errors. " ^self onUpload; checkEasyStatus; perform; checkEasyStatus; readRewind! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 9/13/2006 17:04'! url ^url! ! !Curl methodsFor: 'user api - basic' stamp: 'dao 10/1/2006 16:41'! url: aString "set url for the next transfer, raise walkbacks on errors" url := aString. self pEasy: handle Url: aString. self checkEasyStatus! ! !Curl methodsFor: 'user api - auth options' stamp: 'dao 10/1/2006 16:41'! userPwd: aString "[user name]:[password] to use for the connection" self pEasy: handle UserPwd: aString. self checkEasyStatus. ^self! ! TestCase subclass: #CurlFtpTests instanceVariableNames: 'ftpContents' classVariableNames: '' poolDictionaries: '' category: 'Curl-Tests'! !CurlFtpTests methodsFor: 'ftpConfig' stamp: 'dao 10/1/2006 14:19'! ftpContents ^ftpContents ifNil: [String streamContents: [:s | 0 to: 10000 do: [:i | s nextPutAll: i printString , 'this is a test'; cr ]]].! ! !CurlFtpTests methodsFor: 'ftpConfig' stamp: 'dao 10/1/2006 13:11'! ftpExistingUrl ^'ftp://127.0.0.1/Upload/tmp/file.dat'! ! !CurlFtpTests methodsFor: 'ftpConfig' stamp: 'dao 10/1/2006 13:12'! ftpLocalWorkDir ^FileDirectory on: 'c:\Danil\Deploy\Upload\tmp' ! ! !CurlFtpTests methodsFor: 'ftpConfig' stamp: 'dao 10/1/2006 13:11'! ftpNonExistingUrl ^'ftp://127.0.0.1/Upload/tmp/nosuchfile.txt'! ! !CurlFtpTests methodsFor: 'ftpConfig' stamp: 'dao 10/1/2006 13:11'! ftpNotWriteableUrl ^'ftp://127.0.0.1/Upload/tmp/tmp.txt'! ! !CurlFtpTests methodsFor: 'setup/teardown' stamp: 'dao 10/1/2006 17:00'! ftpSetUp | fStream | self ftpTestsAreConfigured ifFalse: [^self]. self ftpLocalWorkDir deleteLocalFiles. fStream := self ftpLocalWorkDir forceNewFileNamed: (self ftpExistingUrl findTokens: '/' ) last. fStream nextPutAll: self ftpContents. fStream close.! ! !CurlFtpTests methodsFor: 'ftpConfig' stamp: 'lr 1/30/2010 16:30'! ftpTestsAreConfigured ^false! ! !CurlFtpTests methodsFor: 'ftpConfig' stamp: 'dao 10/1/2006 15:40'! ftpWriteablePath ^'/Upload/tmp/' ! ! !CurlFtpTests methodsFor: 'ftpConfig' stamp: 'dao 10/1/2006 15:38'! ftpWriteableUrl ^'ftp://127.0.0.1' , self ftpWriteablePath , 'tmp.txt'! ! !CurlFtpTests methodsFor: 'setup/teardown' stamp: 'dao 10/1/2006 12:59'! setUp super setUp. self ftpSetUp.! ! !CurlFtpTests methodsFor: 'setup/teardown' stamp: 'dao 10/1/2006 12:33'! tearDown ^super tearDown ! ! !CurlFtpTests methodsFor: 'testing' stamp: 'dao 10/1/2006 17:07'! testFtpDownload | curl contents | self ftpTestsAreConfigured ifFalse: [^self]. curl := Curl new. self shouldnt: [ contents := curl getContentsUrl: self ftpExistingUrl ] raise: Error. self assert: contents = self ftpContents. self should: [curl getContentsUrl: self ftpNonExistingUrl ] raise: Error. ! ! !CurlFtpTests methodsFor: 'testing' stamp: 'dao 10/1/2006 17:06'! testFtpDownloadInfo | curl | self ftpTestsAreConfigured ifFalse: [^self]. "download file" curl := Curl new. curl onFileTime. " ask servers to tell the time of the files" self shouldnt: [ curl getContentsUrl: self ftpExistingUrl ] raise: Error. "< 226 Transfer complete." self assert: curl infoResponseCode = 226. self assert: curl infoSizeDownload = self ftpContents size. self assert: curl infoSpeedDownload > 0. self assert: curl infoContentLengthDownload = self ftpContents size. self assert: curl infoEffectiveUrl = self ftpExistingUrl. self assert: curl infoFtpEntryPath = '/'. self assert: curl infoPrivate = ''. self assert: curl infoContentType = ''. curl infoFileTime ifNil: [^self "some servers don't return time of documents - skip checks in this case"]. self assert: curl infoFileTime <= DateAndTime now. self assert: curl infoFileTime >= DateAndTime now - (Duration hours: 1) " running the test should not take that long :) " ! ! !CurlFtpTests methodsFor: 'testing' stamp: 'dao 10/1/2006 17:05'! testFtpDownloadInfoTimings | curl | self ftpTestsAreConfigured ifFalse: [^self]. "download file" curl := Curl new. self shouldnt: [ curl getContentsUrl: self ftpExistingUrl ] raise: Error. self assert: curl infoRedirectTime = Duration zero. "no redirect" "refer to libcurl man pages for the complete description of time values" self assert: curl infoTotalTime >= curl infoStartTransferTime. self assert: curl infoStartTransferTime >= curl infoPreTransferTime. self assert: curl infoPreTransferTime >= curl infoConnectTime. self assert: curl infoConnectTime >= curl infoNameLookupTime. self assert: curl infoNameLookupTime >= Duration zero. ! ! !CurlFtpTests methodsFor: 'testing' stamp: 'dao 10/1/2006 13:29'! testFtpUpload | curl | self ftpTestsAreConfigured ifFalse: [^self]. curl := Curl new. self shouldnt: [ curl putContents: self ftpContents url: self ftpWriteableUrl ] raise: Error. "the second time we can not write the same url - file exists" self should: [curl putContents: 'whatever' ] raise: Error. ! ! !CurlFtpTests methodsFor: 'testing' stamp: 'dao 10/1/2006 16:11'! testFtpUploadInfo | curl | self ftpTestsAreConfigured ifFalse: [^self]. "upload file" curl := Curl new. curl onFileTime. " ask servers to tell the time of the files" self shouldnt: [ curl putContents: self ftpContents url: self ftpWriteableUrl ] raise: Error. "< 226 Transfer complete." self assert: curl infoResponseCode = 226. self assert: curl infoSizeUpload = self ftpContents size. self assert: curl infoSpeedUpload > 0. self assert: curl infoContentLengthUpload = self ftpContents size. self assert: curl infoEffectiveUrl = self ftpWriteableUrl. self assert: curl infoFtpEntryPath = '/'. self assert: curl infoPrivate = ''. self assert: curl infoContentType = ''. curl infoFileTime ifNil: [^self "some servers don't return time of documents - skip checks in this case"]. self assert: curl infoFileTime <= DateAndTime now. self assert: curl infoFileTime >= DateAndTime now - (Duration hours: 1) " running the test should not take that long :) " ! ! !CurlFtpTests methodsFor: 'testing' stamp: 'dao 10/1/2006 13:40'! testFtpUploadInfoTimings | curl | self ftpTestsAreConfigured ifFalse: [^self]. "upload file" curl := Curl new. self shouldnt: [ curl putContents: self ftpContents url: self ftpWriteableUrl ] raise: Error. self assert: curl infoRedirectTime = Duration zero. "no redirect" "refer to libcurl man pages for the complete description of time values" self assert: curl infoTotalTime >= curl infoStartTransferTime. self assert: curl infoStartTransferTime >= curl infoPreTransferTime. self assert: curl infoPreTransferTime >= curl infoConnectTime. self assert: curl infoConnectTime >= curl infoNameLookupTime. self assert: curl infoNameLookupTime >= Duration zero. ! ! TestCase subclass: #CurlTests instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Curl-Tests'! !CurlTests methodsFor: 'setup/teardown' stamp: 'dao 8/25/2007 23:08'! setUp "force the fresh start for every test" SmalltalkImage current unloadModule: 'CurlPlugin'! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/1/2006 18:27'! testApiBasic "should not fail with good input, should primFail on bad and should not crash, no used memory after destroy" | curl | curl := Curl new. self shouldnt: [curl cancel] raise: Error. self assert: curl contents = nil. self shouldnt: [curl contents: 'whatever'] raise: Error. self should: [curl contents: 123 ] raise: Error. self assert: curl contents = 'whatever'. self shouldnt: [curl clearContents ] raise: Error. self assert: curl contents = nil. self shouldnt: [curl url: 'whatever'] raise: Error. self should: [curl url: 111] raise: Error. curl destroy. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/7/2006 19:59'! testApiHttpAuthOptions "should not fail with good input, should primFail on bad and should not crash, no used memory after destroy" | curl | curl := Curl new. self shouldnt: [curl userPwd: 'whatever'] raise: Error. self shouldnt: [curl proxyUserPwd: 'whatever'] raise: Error. self shouldnt: [curl onHttpAuthBasic] raise: Error. self shouldnt: [curl onHttpAuthDigest ] raise: Error. self shouldnt: [curl onHttpAuthNtlm ] raise: Error. self shouldnt: [curl onHttpAuthAny ] raise: Error. self shouldnt: [curl onHttpAuthAnySafe ] raise: Error. self shouldnt: [curl onProxyAuthBasic] raise: Error. self shouldnt: [curl onProxyAuthDigest ] raise: Error. self shouldnt: [curl onProxyAuthNtlm ] raise: Error. self shouldnt: [curl onProxyAuthAny ] raise: Error. self shouldnt: [curl onProxyAuthAnySafe ] raise: Error. curl destroy. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/8/2006 18:09'! testApiHttpOptions "should not fail with good input, should primFail on bad and should not crash, no used memory after destroy" | curl | curl := Curl new. self shouldnt: [curl onAutoReferer ] raise: Error. self shouldnt: [curl onFollowLocation ] raise: Error. self shouldnt: [curl onGetHeader ] raise: Error. self shouldnt: [curl onHttpGet] raise: Error. self shouldnt: [curl onUnrestrictedAuth ] raise: Error. self shouldnt: [curl onPost ] raise: Error. self shouldnt: [curl maxRedirs: 5 ] raise: Error. self shouldnt: [curl cookieSession ] raise: Error. self shouldnt: [curl cookie: '' ] raise: Error. self shouldnt: [curl cookieFile: 'cookies.txt' ] raise: Error. self shouldnt: [curl cookieJar: 'cookies.jar' ] raise: Error. curl destroy. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/1/2006 18:44'! testApiInfoStrings "all this should be set to zero before the transfer for new handle" | curl | curl := Curl new. self assert: curl infoContentType = ''. self assert: curl infoEffectiveUrl = ''. self assert: curl infoFtpEntryPath = ''. self assert: curl infoPrivate = ''. curl destroy. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/7/2006 19:48'! testApiOptions "should not fail with good input, should primFail on bad and should not crash, no used memory after destroy" | curl | curl := Curl new. self shouldnt: [curl caInfo: 'whatever'] raise: Error. self shouldnt: [curl proxy: 'whatever'] raise: Error. self shouldnt: [curl timeout: 1 ] raise: Error. self shouldnt: [curl userPwd: 'whatever'] raise: Error. self shouldnt: [curl proxyUserPwd: 'whatever'] raise: Error. self shouldnt: [curl url: 'whatever'] raise: Error. self should: [curl caInfo: nil] raise: Error. self should: [curl proxy: 666 ] raise: Error. self should: [curl timeout: 'Wait long ' ] raise: Error. self should: [curl timeout: 10000000 ] raise: Error. self should: [curl userPwd: false ] raise: Error. self should: [curl url: self] raise: Error. curl destroy. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 8/26/2007 21:52'! testApiSupport "should not fail with good input, should primFail on bad and should not crash, no used memory after destroy" | curl | curl := Curl new. self assert: (curl unEscape: (curl escape: 'This is a test for Encoding-Go!!Go!!Go!!')) = 'This is a test for Encoding-Go!!Go!!Go!!'. curl destroy. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/7/2006 20:51'! testApiSwitches "should not fail " | curl | curl := Curl new. self shouldnt: [ curl onFailOnError ] raise: Error. self shouldnt: [ curl onFileTime ] raise: Error. self shouldnt: [ curl onGetHeader ] raise: Error. self shouldnt: [ curl onSSLVerifyPeer ] raise: Error. self shouldnt: [ curl onUpload ] raise: Error. self shouldnt: [ curl onVerbose ] raise: Error. self shouldnt: [ curl onFollowLocation ] raise: Error. self shouldnt: [ curl onUnrestrictedAuth ] raise: Error. self shouldnt: [ curl onHttpProxyTunnel ] raise: Error. self shouldnt: [ curl offFailOnError ] raise: Error. self shouldnt: [ curl offFileTime ] raise: Error. self shouldnt: [ curl offGetHeader ] raise: Error. self shouldnt: [ curl offSSLVerifyPeer ] raise: Error. self shouldnt: [ curl offUpload ] raise: Error. self shouldnt: [ curl offVerbose ] raise: Error. self shouldnt: [ curl offFollowLocation ] raise: Error. self shouldnt: [ curl offUnrestrictedAuth ] raise: Error. self shouldnt: [ curl onHttpProxyTunnel ] raise: Error. curl destroy. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 8/26/2007 17:54'! testApiTimeFromString | curl | curl := Curl new. self assert: ( (Curl timeFromString: '20040912 15:05:58') = (DateAndTime year: 2004 month: 09 day: 12 hour: 15 minute: 05 second: 58)). self should: [Curl timeFromString: 'garbage, not date'] raise: Error. curl destroy. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/1/2006 18:42'! testApiTimings "all this should be set to zero before the transfer - please, dont crash :)" | curl | curl := Curl new. self assert: curl infoConnectTime = Duration zero. self assert: curl infoNameLookupTime = Duration zero. self assert: curl infoPreTransferTime = Duration zero. self assert: curl infoRedirectTime = Duration zero. self assert: curl infoStartTransferTime = Duration zero. self assert: curl infoTotalTime = Duration zero. curl destroy. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/1/2006 18:49'! testApiTransfersParameters "all this should be set to zero before the transfer for new handle" | curl | curl := Curl new. self assert: curl infoContentLengthDownload = 0. self assert: curl infoContentLengthUpload = 0. self assert: curl infoFileTime = (DateAndTime year: 1970 day: 1). self assert: curl infoResponseCode = 0. self assert: curl infoSizeDownload = 0. self assert: curl infoSizeUpload = 0. self assert: curl infoSpeedDownload = 0. self assert: curl infoSpeedUpload = 0. curl destroy. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 8/26/2007 21:04'! testApiVersion "building against this version: libcurl/7.17.0-20070826 OpenSSL/0.9.8b zlib/1.2.3 c-ares/1.4.0 libidn/0.6.3 libssh2/0.17 version of curl should not below 7.16 - lot of bugs fixed" | vStr libDict curlVersion | self assert: ( (vStr := Curl curlVersion) isKindOf: String). libDict := Dictionary new. (vStr findTokens: ' ') do: [:s | [:pair | libDict at: pair first put: pair second] value: (s findTokens: '/') ]. curlVersion := Number readFrom: (libDict at: 'libcurl') readStream. self assert: curlVersion >= 7.17. self assert: Curl pNumberOfMemChunks = 0 ! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/1/2006 17:31'! testInvalidHandleUse | curl | curl := Curl new. self shouldnt: [curl url: 'whatever'] raise: Error. curl destroy. self should: [curl url: 'whatever'] raise: Error "and should not crash :)"! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/1/2006 17:32'! testMassiveCurlHandleCreation | curls | curls := Array streamContents: [:s | 1000 timesRepeat: [s nextPut: (Curl new url: 'whatever') ]]. curls do: [:c | c destroy]. curls := nil. 3 timesRepeat: [Smalltalk garbageCollect]. self assert: (Curl pNumberOfMemChunks = 0)! ! !CurlTests methodsFor: 'testing' stamp: 'dao 10/1/2006 17:21'! testNumberOfMemoryChunks self assert: Curl pNumberOfMemChunks = 0! !