[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/order_editor/ -> http_client.php (summary)

(no description)

File Size: 459 lines (13 kb)
Included or required: 2 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

httpClient:: (23 methods):
  httpClient()
  setProxy()
  setProtocolVersion()
  setCredentials()
  setHeaders()
  addHeader()
  removeHeader()
  Connect()
  Disconnect()
  Head()
  Get()
  Post()
  Put()
  getHeaders()
  getHeader()
  getBody()
  getStatus()
  getStatusMessage()
  sendCommand()
  processReply()
  processHeader()
  processBody()
  makeUri()


Class: httpClient  - X-Ref

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


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

Connect($host, $port = '')   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)

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

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
No description

processHeader($lastLine = "\r\n")   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



Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7