|
Class: HTTPInterface
Object
|
+--HTTPInterface
- Package:
- stx:goodies/communication
- Category:
- Net-Communication-HTTP-Client
- Version:
- rev:
1.321
date: 2019/07/17 17:55:40
- user: cg
- file: HTTPInterface.st directory: goodies/communication
- module: stx stc-classLibrary: communication
- Author:
- Claus Gittinger
An HTTP interface (i.e. a client) which is able to fetch documents using
HTTP GET, HEAD and POST commands.
- can use HTTP 0.9, HTTP 1.0 or HTTP 1.1 (default)
HTTP 1.1 is defined in RFC2068.
- keeps track of open socket connections and can keep busy connections open.
- long contents (with configurable size limit) are stored into a temporary file
and the fileName is provided instead of the contents.
This is useful if huge files are to be transferred.
- define a proxy by answering to HTTPProxyQuery with an instance of HTTPProxySettings.
(or use the withProxy:do: entry)
Caveat:
I cannot guarantee that all HTTP 1.1 features are correctly implemented (as usual).
However, it seems to work for our applications.
[class variables:]
USEREL0_9 - if true, HTTP 0.9 protocol is used
USEREL1_0 - if true, HTTP 1.0 protocol is used
if both are false, HTTP 1.1 is used.
Logging - if true, protocol info is sent to Transcript
TransferInformationSignal - raised to pass transfer information; param is ASCII text telling
caller what is currently been done (connecting etc.)
Can be used by GUI to show connection state.
TransferProgressNotificationSignal - raised to pass transfer information; param is percentage of xferred data
Can be used by GUI to show progress info.
UnsupportedOperationNotificationSignal - HTTP server does not support operation
ContentTypeInformationSignal - content-type of document as about to be xferred.
WrongContentTypeNotificationSignal - content of document is not as specified in allowedMimeTypes arg.
If proceeded, the document is xferred as usual.
TransferTimeoutNotificationSignal - xfer timeout
ShortTransferNotificationSignal - short document
CookieStoreRequestSignal - HTTP server wants to install a cookie
DefaultTransferTimeout - various defaults
KeepAliveConnections
MaxNumberOfKeptConnections
HTTPServer
HTTPService
http://www.w3.org/Protocols/rfc2616/rfc2616.html
Signal constants
-
contentTypeInformationSignal
-
-
cookieStoreRequestSignal
-
-
shortTransferNotificationSignal
-
-
transferInformationSignal
-
-
transferProgressNotificationSignal
-
-
transferTimeoutNotificationSignal
-
-
unsupportedOperationNotificationSignal
-
-
wrongContentTypeNotificationSignal
-
debugging
-
logging: aBoolean
-
enable/disable logging
usage example(s):
self logging:true
self logging:false
|
defaults
-
defaultConnectTimeout
-
return the default connect timeout
usage example(s):
HTTPInterface defaultConnectTimeout
HTTPInterface defaultConnectTimeout:120
HTTPInterface defaultConnectTimeout:30
|
-
defaultConnectTimeout: seconds
-
set the default connect timeout
usage example(s):
HTTPInterface defaultConnectTimeout
HTTPInterface defaultConnectTimeout:120
HTTPInterface defaultConnectTimeout:30
|
-
defaultTransferTimeout
-
return the default transfer timeout;
that is the max. time from request to data xmission start
usage example(s):
HTTPInterface defaultTransferTimeout
HTTPInterface defaultTransferTimeout:120
HTTPInterface defaultTransferTimeout:30
|
-
defaultTransferTimeout: seconds
-
set the default transfer timeout;
that is the max. time from request to data xmission start
usage example(s):
HTTPInterface defaultTransferTimeout
HTTPInterface defaultTransferTimeout:120
HTTPInterface defaultTransferTimeout:30
|
-
maxContentsLengthForDirectData
-
if a files size is smaller than the value returned by this method, then a bytearray-buffer
is used for the data; otherwise, the data is stored in a temporary file and
the dataFile is passed in the response object.
-
maxNumberOfKeptConnections
-
return the max. number of kept connections
-
maxNumberOfKeptConnections: numKept
-
set the max. number of kept connections
usage example(s):
self maxNumberOfKeptConnections
self maxNumberOfKeptConnections:3
self maxNumberOfKeptConnections:1
|
initialization
-
closeKeptConnections
-
-
initialize
-
for now, simulate a Mozilla;
usage example(s):
instance creation
-
connectTo: anUrlorUrlString
-
create an instance to myself and connect it to anUrlorUrlString
-
connectTo: hostName port: portNrOrNil
-
create an instance to myself and connect it to portNr on hostName.
If portNr is nil, the default http port will be used.
-
connectTo: hostName port: portNrOrNil useSSL: useSSL
-
create an instance to myself and connect it to portNr on hostName.
If portNr is nil, the default http port will be used.
-
connectTo: hostName port: portNrOrNil useSSL: sslRequested sslVersion: sslVersionOrNil sslSuite: sslSuiteOrNil
-
create an instance to myself and connect it to portNr on hostName.
If portNr is nil, the default http port will be used.
-
connectToHost: host port: port viaProxy: httpProxySettings
-
connect a socket via a proxy.
Answer the connected socket.
THis is not HTTP specific. You can use this socket to connect to any service through a tunnel.
(Although it has to be allowed by the proxy - e.g. in Apache:'AllowCONNECT 443 5222'
-
new
-
(comment from inherited method)
return an instance of myself without indexed variables
private helpers
-
extractCharSetEncodingFromContentType: arg
-
-
extractMimeTypeFromContentType: arg
-
-
generateFieldDataFrom: nameValueAssociations
-
allow for both dictionaries and seqColls of associations
-
logInfo: msg
-
Logging := false
Logging := true
-
logVerboseInfo: msg
-
Logging := false
Logging := true
-
multiPartBoundaryPost: url filename: aFilename fileNameFieldName: aFilenameFieldName contents: contents otherValues: aValueDict
-
a post request with field values in a smalltalk-friendly form
-
numericReturnCodeForSymbol: aSymbolicHttpReturnCode
-
given a symbolic error code, return the corresponding HTTP code
usage example(s):
self numericReturnCodeForSymbol:#'NOT_FOUND' -> 404
self symbolForReturnCode:404 -> #'NOT_FOUND'
|
-
putAcceptString: aStringOrCollection for: what on: aStream
-
self putAcceptString:nil for:'Accept-Encoding' on:Transcript
self putAcceptString:'gzip' for:'Accept-Encoding' on:Transcript
self putAcceptString:#('gzip') for:'Accept-Encoding' on:Transcript
self putAcceptString:#('gzip' 'tar' 'bzip') for:'Accept-Encoding' on:Transcript
-
request: getOrPost url: urlOrPathOrNil fromHost: hostOrNil port: portNrOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: user password: passwd
-
Modified (format): / 08-02-2019 / 15:16:56 / Claus Gittinger
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
symbolForReturnCode: aNumericHttpReturnCode
-
-
transferRateStringFor: bytesTransferedPerSecond
-
request API
-
delete: url
-
a delete request. Usually only useful against a Rest service.
returns a response object
usage example(s):
HTTPInterface
delete:'http://someURL'.
|
-
delete: url userName: aUserName password: aPassword
-
a delete request. Usually only useful against a Rest service.
returns a response object
-
get: url
-
get url;
returns a response-object
usage example(s):
HTTPInterface get:'http://www.exept.de/'
HTTPInterface get:'http://foo.bar.baz/'
|
-
get: url accept: acceptedMimeTypes
-
get url, accepting types in acceptedMimeTypes.
Returns a response-object.
usage example(s):
HTTPInterface
get:'http://www.exept.de/'
accept:#('image/gif' 'image/xbm' 'text/html')
HTTPInterface
get:'http://www.google.de/'
accept:#('image/gif')
|
-
get: url destinationFile: destinationFilename
-
get url;
returns a response-object.
Data is stored in destinationFile
usage example(s):
HTTPInterface get:'http://www.exept.de/'
HTTPInterface get:'http://foo.bar.baz/'
|
-
get: url fromDocument: referrer
-
get url with referrer;
returns a response-object
usage example(s):
HTTPInterface get:'http://www.exept.de/'
HTTPInterface get:'http://foo.bar.baz/'
|
-
get: path fromHost: host
-
get path from host.
Returns a response-object.
usage example(s):
HTTPInterface
get:'/'
fromHost:'www.exept.de'
|
-
get: path fromHost: host port: portNr
-
get path from host.
If port is not nil, it is a SmallInteger used instead of the default port.
Returns a response-object.
usage example(s):
HTTPInterface
get:'/'
fromHost:'www.exept.de'
port:8080
|
-
get: path fromHost: host port: portNrOrNil accept: acceptedMimeTypes fromDocument: documentURL
-
get path from host.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
-
get: urlOrPath fromHost: host port: portNrOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: user password: passwd
-
get url from host.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
usage example(s):
HTTPInterface get:'/' fromHost:'porty'
port:nil fromDocument:'http://murks'
|
-
get: urlOrPath fromHost: host port: portNrOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: user password: passwd cookies: aCollectionOfCookiesOrNil
-
get url from host.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
usage example(s):
HTTPInterface get:'/' fromHost:'porty'
port:nil fromDocument:'http://murks'
|
-
get: urlOrPath fromHost: host port: portNrOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: user password: passwd cookies: aCollectionOfCookiesOrNil maxCountFollowMoved: maxCountFollowed
-
get url from host.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
If the response is a moved-file response, follow the indirection, but at most maxCountFollowed times.
Returns a response-object.
-
get: urlOrPath fromHost: host port: portNrOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: user password: passwd maxCountFollowMoved: maxCountFollowed
-
get url from host.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
If the response is a moved-file response, follow the indirection, but at most maxCountFollowed times.
Returns a response-object.
-
get: path fromHost: host port: portNrOrNil fromDocument: documentURL
-
get path from host.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
-
get: url port: portNr
-
get url;
returns a response-object
usage example(s):
HTTPInterface get:'http://www.exept.de/'
HTTPInterface get:'http://foo.bar.baz/'
|
-
get: url userName: user password: password
-
get url;
Returns a response-object.
usage example(s):
HTTPInterface
get:'http://www.exept.de/'
userName:'foo'
password:'bar'
|
-
get: url with: data
-
a get request with field values in HTTP-request form (&nameKey=value;).
returns a response-object
-
get: url withFields: nameValueAssociations
-
a get request with field values.
returns a response-object
-
getFile: url
-
a get request,
returning the data if present, or else raising an error.
usage example(s):
self getFile:'http://www.exept.de/'
self getFile:'http://www.google.com/'
self getFile:'http://webservices.daehosting.com/services/isbnservice.wso?WSDL'
|
-
getFile: url userName: aUserName password: aPassword
-
a get request,
returning the data if present, or else raising an error.
-
getStreamFor: url
-
a get request,
returning a stream on the data if present, or else raising an error.
usage example(s):
self getStreamFor:'http://www.exept.de/'
self getStreamFor:'http://www.google.com/'
self getStreamFor:'http://webservices.daehosting.com/services/isbnservice.wso?WSDL'
|
-
head: url accept: acceptedMimeTypes
-
get a documents head (i.e. without body) url from host.
Returns a response-object.
usage example(s):
HTTPInterface
head:'http://www.exept.de/'
accept:#('image/gif' 'image/xbm' 'text/html')
HTTPInterface
head:'http://www.google.de/'
accept:#('image/gif')
|
-
head: urlOrPath fromHost: host port: portNrOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: user password: passwd cookies: aCollectionOfCookiesOrNil
-
get a documents head (i.e. without body) url from host.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
usage example(s):
HTTPInterface head:'/' fromHost:'www.exept.de'
port:nil accept:#('*') fromDocument:'/'
userName:nil password:nil cookies:nil
HTTPInterface get:'/' fromHost:'www.exept.de'
port:nil accept:#('*') fromDocument:'/'
userName:nil password:nil cookies:nil
|
-
multiPartBoundaryPost: url fromHost: host port: port userName: userName password: password attributes: aValueDict
-
a post request with field values in a smalltalk-friendly for;
returns a response object
-
post: path host: host port: port with: data
-
a post request with field values in HTTP-request form (&nameKey=value;);
returns a response object
usage example(s):
HTTPInterface
post:'/m5?a=1&s=USD&t=EUR'
host:'se.finance.yahoo.com'
port:80
with:'foo=1&bar=2'
|
-
post: path host: host port: port withFields: nameValueAssociations
-
returns a response object
usage example(s):
HTTPInterface
post:'/m5?a=1&s=USD&t=EUR'
host:'se.finance.yahoo.com'
port:80
withFields:(Dictionary new at:'foo' put:'1'; at:'bar' put:'2'; yourself)
|
-
post: url userName: aUserName password: aPassword with: data
-
a post request with field values in HTTP-request form (&nameKey=value;);
returns a response object
-
post: url userName: aUserName password: aPassword with: data contentType: aType
-
a post request with field values in HTTP-request form (&nameKey=value;);
returns a response object
-
post: url with: data
-
a post request with field values in HTTP-request form (&nameKey=value;);
returns a response object
usage example(s):
HTTPInterface
post:'http://se.finance.yahoo.com/m5?a=1&s=USD&t=EUR' with:'foo=1&bar=2'
|
-
post: url with: data contentType: mimeType
-
a post request with field values in HTTP-request form (&nameKey=value;);
returns a response object
usage example(s):
HTTPInterface
post:'http://se.finance.yahoo.com/m5?a=1&s=USD&t=EUR' with:'foo=1&bar=2'
|
-
post: url withFields: nameValueAssociations
-
returns a response object
usage example(s):
HTTPInterface
post:'http://se.finance.yahoo.com/m5?a=1&s=USD&t=EUR'
withFields:(Dictionary new at:'foo' put:'1'; at:'bar' put:'2'; yourself)
|
-
processRedirectsFor: anUrl with: fetchBlock
-
utility:
evaluate fetchBlock with anUrl, if error, raise it. If moved, get the moved document;
answer the response.
-
put: url userName: aUserName password: aPassword with: data contentType: mimeTypeOfData
-
a put request with data;
returns a response object
usage example(s):
HTTPInterface
put:'http://someURL' with:'someData' contentType:'text/plain'.
HTTPInterface
put:'http://someURL' with:'someData' contentType:nil.
|
-
put: url with: data contentType: mimeTypeOfData
-
a put request with data;
returns a response object
usage example(s):
HTTPInterface
put:'http://someURL' with:'someData' contentType:'text/plain'.
HTTPInterface
put:'http://someURL' with:'someData' contentType:nil.
|
-
request: getOrPost url: urlOrPathArgOrNil fromHost: hostOrNil port: portNrOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: userOrNil password: passwordOrNil contentType: contentType contents: contents
-
send a get/post request to host.
If urlOrPathArgOrNil is nil, host must be non-nil;
if host is nil, urlOrPathArgOrNil must be non-nil.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
-
request: getOrPost url: urlOrPathArgOrNil fromHost: hostOrNil port: portNrOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: userOrNil password: passwordOrNil contentType: contentType contents: contents destinationFile: destinationFilenameOrNil
-
send a get/post request to host.
If urlOrPathArgOrNil is nil, host must be non-nil;
if host is nil, urlOrPathArgOrNil must be non-nil.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
-
request: getOrPost url: urlOrPathArgOrNil fromHost: hostOrNil port: portNrOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: userOrNil password: passwordOrNil cookies: aCollectionOfCookiesOrNil contentType: contentType contents: contents destinationFile: destinationFilenameOrNil
-
send a get/post request to host.
If urlOrPathArgOrNil is nil, host must be non-nil;
if host is nil, urlOrPathArgOrNil must be non-nil.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
-
request: getOrPost url: urlOrPathArgOrNil fromHost: hostOrNil port: portNrOrNil proxy: proxySettingsOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: userOrNil password: passwordOrNil contentType: contentType contents: contents destinationFile: destinationFilenameOrNil
-
send a get/post request to host.
If urlOrPathArgOrNil is nil, host must be non-nil;
if host is nil, urlOrPathArgOrNil must be non-nil.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
-
request: getOrPost url: urlOrPathArgOrNil fromHost: hostOrNil port: portNrOrNil proxy: proxySettingsOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: userOrNil password: passwordOrNil cookies: aCollectionOfCookiesOrNil contentType: contentType contents: contents destinationFile: destinationFilenameOrNil
-
send a get/post request to host.
If urlOrPathArgOrNil is nil, host must be non-nil;
if host is nil, urlOrPathArgOrNil must be non-nil.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
-
request: getOrPost url: urlOrPathArgOrNil fromHost: hostOrNil port: portNrOrNil proxy: proxySettingsOrNil accept: acceptedMimeTypes fromDocument: documentURL userName: userOrNil password: passwordOrNil cookies: aCollectionOfCookiesOrNil contentType: contentType contents: contents destinationFile: destinationFilenameOrNil additionalHeaderLines: additionalHeaderLinesOrNil
-
send a get/put/post request to host.
If urlOrPathArgOrNil is nil, host must be non-nil;
if host is nil, urlOrPathArgOrNil must be non-nil.
If port is not nil, it is a SmallInteger used instead of the default port.
DocumentUrl may be nil or a String containing the url of the referring document.
Returns a response-object.
-
withProxy: proxySettingsOrNil do: aBlock
-
utility function:
perform the request through the proxy defined in proxySettingsOrNil
usage example(s):
self withProxy:(HTTPProxySettings useHost:'fooBar' port:1234) do:[ HTTPInterface get:'http://www.exept.de' ]
self withProxy:nil do:[ HTTPInterface get:'http://www.exept.de' ]
|
-
withProxy: proxySettingsOrNil useSsl: useSsl do: aBlock
-
utility function:
perform the request through the proxy defined in proxySettingsOrNil
if useSsl is set to true, forces url method https if method is http
usage example(s):
self
withProxy:(HTTPProxySettings useHost:'fooBar' port:1234)
useSsl:true
do:[
HTTPInterface get:'http://www.exept.de'
]
self
withProxy:nil
useSsl:false
do:[
HTTPInterface get:'http://expeccoalm.exept.de'
]
|
validation
-
validateAStringOnW3Org: aString
-
do not remove, application runs asynchronous"
usage example(s):
self validateAStringOnW3Org:''
|
accessing
-
acceptedCharsets
-
-
acceptedCharsets: acceptedCharsetsStringOrNil
-
Modified (format): / 20-01-2019 / 00:40:49 / Claus Gittinger
-
acceptedCharsets: acceptedCharsetsStringOrNil acceptedMimeTypes: acceptedMimeTypesStringOrNil
-
-
acceptedEncodings
-
-
acceptedEncodings: acceptedEncodingsString
-
Modified (format): / 20-01-2019 / 00:39:52 / Claus Gittinger
-
acceptedEncodings: acceptedEncodingsString acceptedLanguages: acceptedLanguagesStringOrNil
-
-
acceptedLanguages
-
-
acceptedLanguages: acceptedLanguagesStringOrNil
-
Modified (format): / 20-01-2019 / 00:40:12 / Claus Gittinger
-
acceptedMimeTypes
-
-
acceptedMimeTypes: acceptedMimeTypesStringOrNil
-
Modified (format): / 20-01-2019 / 00:40:58 / Claus Gittinger
-
additionalHeaderLines
-
-
additionalHeaderLines: something
-
-
bindTo: anIpSocketAddress
-
use anIpSocketAddress as originating IP address
-
connectTimeout
-
the connectionTimeout in seconds
-
connectTimeout: something
-
set the connectionTimeout in seconds
-
contentType
-
-
contentType: contentTypeString
-
Modified (format): / 20-01-2019 / 00:41:43 / Claus Gittinger
-
contents
-
-
contents: something
-
-
contents: something contentType: contentTypeString
-
-
cookies
-
-
cookies: aCollectionOfCookiesOrNil
-
the cookies to send
-
destinationFile: aFilename
-
if given, received data will be stored there, instead of being returned
as string/byteAray. use this for big file transfers
-
host: hostArg port: portArg
-
-
keepConnection
-
-
keepConnection: aBoolean
-
if aBoolean is false, the connection will be closed
after request is finished.
If aBoolean is true, the server determines if the connection
is kept in a connection cache.
-
maxContentsLengthForDirectData: anInteger
-
if given, that is the maximum size of received data to be returned directly as
ByteArray/String. If the received document is larger, it will be stored into a
tempfile and that file's name is found in the dataFile slot of the response data.
If left undefined, a default value (currently 4Mb) is used as a maximum
-
password
-
-
password: passwordStringOrNil
-
Modified (format): / 20-01-2019 / 00:38:52 / Claus Gittinger
-
proxySettings
-
-
proxySettings: something
-
-
referer
-
Notice the misspelling - due to the fact that the misspelling made it into
the HTTP standard
-
referer: something
-
Notice the misspelling - due to the fact that the misspelling made it into
the HTTP standard
-
referrer
-
Notice the misspelling below - due to the fact that the misspelling made it into
the HTTP standard
-
referrer: something
-
Notice the misspelling below - due to the fact that the misspelling made it into
the HTTP standard
-
request: aRequestString
-
-
requestWebSocket: aBoolean
-
-
socket
-
-
socket: aSocket
-
-
sslSuite
-
-
sslSuite: something
-
-
sslVersion
-
the ssl version used (i.e. SSL::SSLProtocolVersion tls12).
If left undefined, the current default version is used
-
sslVersion: anSSLProtocolVersionOrNil
-
set the ssl version (i.e. SSL::SSLProtocolVersion tls12).
If left undefined, the current default version is used
-
suppressUnicode: aBoolean
-
-
transferTimeout
-
the transferTimeout in seconds
-
transferTimeout: seconds
-
set the transferTimeout in seconds
-
userAgent
-
-
userAgent: something
-
-
userName
-
-
userName: userNameStringOrNil
-
Modified (format): / 20-01-2019 / 00:39:06 / Claus Gittinger
-
userName: userNameStringOrNil password: passwordStringOrNil
-
helpers
-
authenticationStringForUser: user password: passwd
-
|s|
s := Base64Coder encode:('ca' , ':' , 'ca').
^ (Base64Coder decode:s) asString
-
basicDoRequest: getOrPostOrWhat
-
Send a request and expect a response. Return nil or a response.
The retrieved data is provided as:
- destinationFile's contents, if a destinationFile was given
- direct data (in response data), if the retrieved data is not too big
- a temporary dataFile, for large files.
-
close
-
-
closeSocket
-
-
doRequest: getOrPostOrWhat
-
proxy requires full URL
-
establishSocketToHost: connectHost port: connectPort
-
establish the socket connection
-
extractTransferParametersFromInfo: info
-
-
getResponse
-
-
logInfo: arg
-
-
logVerboseInfo: arg
-
-
receiveDocument
-
post a rangeGet ...
-
socketHandlingAfterRequestWithResponse: responseArg
-
cache the connection/socket for future requests.
Whether we do caching, depends on the returned HTTP response
initialization
-
connect
-
establish the connection, use the parameters stored in
my instance variables.
usage example(s):
cleanup old closed kept connections
|
usage example(s):
we are going to re-use the connection, so it is no longer available
|
-
connectTo: anUrl
-
get the parameters to connect from anURL and do the connect.
If host an port is explicitely set, they have precedence over
the values from anUrl.
-
connectTo: hostName port: portNrOrNil
-
|h|
h := HTTPInterface new connectTo:'exept.de' port:nil.
Transcript showCR:(h requestGET:'/').
h close.
-
connectTo: hostName port: portNrOrNil useSSL: sslRequested
-
|h reply|
h := HTTPInterface new connectTo:'www.google.de' port:nil useSSL:true.
reply := h requestGET:'/'.
h close.
reply inspect.
-
connectTo: hostName port: portNrOrNil useSSL: sslRequested sslVersion: sslProtocolVersionOrNil sslSuite: sslSuiteOrNil
-
|reply|
Transcript showCR:(Time millisecondsToRun:[
|h|
h := HTTPInterface new
connectTo:'exept.de' port:nil
useSSL:true
sslVersion: SSL::SSLProtocolVersion tls11
sslSuite:SSL::TlsRsaWithAes256CbcSha new.
reply := h requestGET:'/'.
h close.
]).
reply inspect.
-
connectViaProxy: httpProxySettings
-
establish a proxy connection to proxyHost:proxyPort.
Answer the connected socket.
-
initialize
-
DefaultUserAgent := 'Mozilla/4.5 [en] (STX)'
DefaultConnectTimeout := 30
DefaultTransferTimeout := 30
queries
-
dataBufferSize
-
^ 16384
-
isConnected
-
release
-
destroy
-
requests
-
request: getOrPostOrDeleteOrWhateverUppercaseHTTPCommand url: urlArg
-
perform any HTTP request, possibly through a proxy
-
requestDELETE: args url: urlArg
-
perform an HTTP DELETE-request
-
requestGET: urlArg
-
Modified (format): / 05-10-2011 / 18:18:00 / cg
-
requestHEAD: urlArg
-
Modified (format): / 05-10-2011 / 18:17:45 / cg
-
requestPOST: args url: urlArg
-
-
requestPUT: args url: urlArg
-
requests - obsolete backward compatibility
-
request: getOrPost url: urlArg acceptedEncodings: acceptedEncodingsArg acceptedLanguages: acceptedLanguagesArg acceptedCharsets: acceptedCharsetsArg acceptedMimeTypes: acceptedMimeTypesArg additionalHeaderLines: additionalHeaderLinesArg contentType: contentTypeArg contents: contentsArg from: currentURL
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
request: getOrPost url: urlArg acceptedEncodings: acceptedEncodingsArg acceptedLanguages: acceptedLanguagesArg acceptedCharsets: acceptedCharsetsArg acceptedMimeTypes: acceptedMimeTypesArg additionalHeaderLines: additionalHeaderLinesArg contentType: contentTypeArg contents: contentsArg from: refererArg userName: userNameArg password: passwordArg
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
request: getOrPost url: urlArg acceptedEncodings: acceptedEncodingsArg acceptedLanguages: acceptedLanguagesArg acceptedCharsets: acceptedCharsetsArg acceptedMimeTypes: acceptedMimeTypesArg from: refererArg
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
request: getOrPost url: urlArg acceptedEncodings: acceptedEncodingsArg acceptedLanguages: acceptedLanguagesArg acceptedCharsets: acceptedCharsetsArg acceptedMimeTypes: acceptedMimeTypesArg from: refererArg userName: userNameArg password: passwordArg
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
requestGET: url accept: acceptedMimeTypes
-
Get url.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
requestGET: url accept: acceptedMimeTypes from: currentURL
-
Get url. If currentUrl is not nil, this is the referer
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
requestGET: url accept: acceptedMimeTypes from: currentURL userName: user password: passwd
-
Get url. If currentUrl is not nil, this is the referer
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
requestGET: urlArg from: refererString
-
Get url. If referer is not nil, this is the referer.
Notice the wrong spelling of referer, which made it into the W3C standard;
written this way to make searching easier.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
HTTPCookie
HTTPResponse
KeptSocketInfo
RequestInformationSignal
TransferProgressNotificationSignal
TransferTimeoutNotificationSignal
WebSocketResponse
WebSocketStream
simple fetch (preferred):
|rply document|
rply := HTTPInterface get:'https://www.howsmyssl.com/'.
rply isErrorResponse ifFalse:[
document := rply data asString.
HTMLDocumentView openOnText:document.
]
|
simple fetch (preferred):
via https (requires the SSL support package to be loaded):
|rply document|
rply := HTTPInterface get:'https://www.exept.de'.
rply isErrorResponse ifFalse:[
document := rply data asString.
HTMLDocumentView openOnText:document.
]
|
old interface:
|rply document|
rply := HTTPInterface get:'/' fromHost:'www.exept.de' port:443.
rply isErrorResponse ifFalse:[
document := rply data asString.
HTMLDocumentView openOnText:document.
]
|
alternative:
|h reply|
h := HTTPInterface connectTo:'https://www.exept.de:443'.
(h requestGET:'/') inspect.
h closeSocket.
|
write data to a temp file:
|h reply|
h := HTTPInterface connectTo:'https://www.exept.de'.
h maxContentsLengthForDirectData:0.
reply := h requestGET:'/'.
reply inspect.
reply dataStream inspect.
h closeSocket.
|
via a proxy:
|rply document|
HTTPInterface
withProxy:(HTTPProxySettings useHost:'exeptn.bh.exept.de' port:8088 user:'proxyuser' password:'password')
do:[
rply := HTTPInterface get:'https://www.exept.de/'.
].
rply isErrorResponse ifTrue:[
rply inspect.
] ifFalse:[
document := rply data.
HTMLDocumentView openOnText:document.
].
|
request a webSocket:
|rply webSocket|
rply := HTTPInterface get:'ws://127.0.0.1:9229/3822cd54-9b67-4d57-bde8-6d4aa91316b2'.
rply isErrorResponse ifFalse:[
webSocket := rply socket.
webSocket inspect.
]
|
|