[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/inc/ -> class.net_http_client.inc.php (sommaire)

(pas de description)

Poids: 869 lignes (27 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

net_http_client:: (34 méthodes):
  net_http_client()
  setDebug()
  setProxy()
  setProtocolVersion()
  setCredentials()
  setHeaders()
  addHeader()
  removeHeader()
  addCookie()
  removeCookies()
  Connect()
  Disconnect()
  Head()
  Get()
  Options()
  Post()
  Put()
  Move()
  Copy()
  MkCol()
  Delete()
  PropFind()
  Lock()
  Unlock()
  getHeaders()
  getHeader()
  getBody()
  getStatus()
  getStatusMessage()
  sendCommand()
  processReply()
  processHeader()
  processBody()
  makeUri()


Classe: net_http_client  - X-Ref

net_http_client( $host= NULL, $port= NULL )   X-Ref
net_http_client
constructor
Note : when host and port are defined, the connection is immediate


setDebug( $level )   X-Ref
turn on debug messages

param: level a combinaison of debug flags

setProxy( $proxyHost, $proxyPort )   X-Ref
turn on proxy support

param: proxyHost proxy host address eg "proxy.mycorp.com"
param: proxyPort proxy port usually 80 or 8080

setProtocolVersion( $version )   X-Ref
setProtocolVersion
define the HTTP protocol version to use

param: version string the version number with one decimal: "0.9", "1.0", "1.1"
return: boolean false if the version number is bad, true if ok

setCredentials( $username, $password )   X-Ref
set a username and password to access a protected resource
Only "Basic" authentication scheme is supported yet

param: username string - identifier
param: password string - clear password

setHeaders( $headers )   X-Ref
define a set of HTTP headers to be sent to the server
header names are lowercased to avoid duplicated headers

param: headers hash array containing the headers as headerName => headerValue pairs

addHeader( $headerName, $headerValue )   X-Ref
addHeader
set a unique request header

param: headerName the header name
param: headerValue the header value, ( unencoded)

removeHeader( $headerName )   X-Ref
removeHeader
unset a request header

param: headerName the header name

addCookie( $cookiename, $cookievalue )   X-Ref
addCookie
set a session cookie, that will be used in the next requests.
this is a hack as cookie are usually set by the server, but you may need it
it is your responsabilty to unset the cookie if you request another host
to keep a session on the server

param: string the name of the cookie
param: string the value for the cookie

removeCookies()   X-Ref
removeCookie
unset cookies currently in use


Connect( $host, $port = NULL )   X-Ref
Connect
open the connection to the server

param: host string server address (or IP)
param: port string server listening port - defaults to 80
return: boolean false is connection failed, true otherwise

Disconnect()   X-Ref
Disconnect
close the connection to the  server


Head( $uri )   X-Ref
head
issue a HEAD request

param: uri string URI of the document
return: string response status code (200 if ok)

Get( $url )   X-Ref
get
issue a GET http request

param: uri URI (path on server) or full URL of the document
return: string response status code (200 if ok)

Options( $url )   X-Ref
Options
issue a OPTIONS http request

param: uri URI (path on server) or full URL of the document
return: array list of options supported by the server or NULL in case of error

Post( $uri, $query_params="" )   X-Ref
Post
issue a POST http request

param: uri string URI of the document
param: query_params array parameters to send in the form "parameter name" => value
return: string response status code (200 if ok)

Put( $uri, $filecontent )   X-Ref
Put
Send a PUT request
PUT is the method to sending a file on the server. it is *not* widely supported

param: uri the location of the file on the server. dont forget the heading "/"
param: filecontent the content of the file. binary content accepted
return: string response status code 201 (Created) if ok

Move( $srcUri, $destUri, $overwrite=true, $scope=0 )   X-Ref
Send a MOVE HTTP-DAV request
Move (rename) a file on the server

param: srcUri the current file location on the server. dont forget the heading "/"
param: destUri the destination location on the server. this is *not* a full URL
param: overwrite boolean - true to overwrite an existing destinationn default if yes
return: string response status code 204 (Unchanged) if ok

Copy( $srcUri, $destUri, $overwrite=true, $scope=0)   X-Ref
Send a COPY HTTP-DAV request
Copy a file -allready on the server- into a new location

param: srcUri the current file location on the server. dont forget the heading "/"
param: destUri the destination location on the server. this is *not* a full URL
param: overwrite boolean - true to overwrite an existing destination - overwrite by default
return: string response status code 204 (Unchanged) if ok

MkCol( $uri )   X-Ref
Send a MKCOL HTTP-DAV request
Create a collection (directory) on the server

param: uri the directory location on the server. dont forget the heading "/"
return: string response status code 201 (Created) if ok

Delete( $uri, $scope=0)   X-Ref
Delete a file on the server using the "DELETE" HTTP-DAV request
This HTTP method is *not* widely supported
Only partially supports "collection" deletion, as the XML response is not parsed

param: uri the location of the file on the server. dont forget the heading "/"
return: string response status code 204 (Unchanged) if ok

PropFind( $uri, $scope=0 )   X-Ref
PropFind
implements the PROPFIND method
PROPFIND retrieves meta informations about a resource on the server
XML reply is not parsed, you'll need to do it

param: uri the location of the file on the server. dont forget the heading "/"
param: scope set the scope of the request.
return: string response status code - 207 (Multi-Status) if OK

Lock( $uri, $lockScope, $lockType, $lockOwner )   X-Ref
Lock - WARNING: EXPERIMENTAL
Lock a ressource on the server. XML reply is not parsed, you'll need to do it

param: $uri URL (relative) of the resource to lock
param: $lockScope -  use "exclusive" for an eclusive lock, "inclusive" for a shared lock
param: $lockType - acces type of the lock : "write"
param: $lockScope -  use "exclusive" for an eclusive lock, "inclusive" for a shared lock    
param: $lockOwner - an url representing the owner for this lock
return: server reply code, 200 if ok

Unlock( $uri, $lockToken )   X-Ref
Unlock - WARNING: EXPERIMENTAL
unlock a ressource on the server

param: $uri URL (relative) of the resource to unlock
param: $lockToken  the lock token given at lock time, eg: opaquelocktoken:e71d4fae-5dec-22d6-fea5-00a0c91e6be4
return: server reply code, 204 if ok

getHeaders()   X-Ref
getHeaders
return the response headers
to be called after a Get() or Head() call

return: array headers received from server in the form headername => value

getHeader( $headername )   X-Ref
getHeader
return the response header "headername"

param: headername the name of the header
return: header value or NULL if no such header is defined

getBody()   X-Ref
getBody
return the response body
invoke it after a Get() call for instance, to retrieve the response

return: string body content

getStatus()   X-Ref
getStatus return the server response's status code

return: string a status code

getStatusMessage()   X-Ref
getStatusMessage return the full response status, of the form "CODE Message"
eg. "404 Document not found"

return: string the message

sendCommand( $command )   X-Ref
send a request
data sent are in order
a) the command
b) the request headers if they are defined
c) the request body if defined

return: string the server repsonse status code

processReply()   X-Ref
Pas de description

processHeader( $lastLine = CRLF )   X-Ref
processHeader() reads header lines from socket until the line equals $lastLine

return: array of headers with header names as keys and header content as values

processBody()   X-Ref
processBody() reads the body from the socket
the body is the "real" content of the reply

return: string body content

makeUri( $uri )   X-Ref
Calculate and return the URI to be sent ( proxy purpose )

param: the local URI
return: URI to be used in the HTTP request



Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7