com.caucho.quercus.lib.curl
Class CurlResource

java.lang.Object
  extended by com.caucho.quercus.env.Value
      extended by com.caucho.quercus.env.ResourceValue
          extended by com.caucho.quercus.lib.curl.CurlResource
All Implemented Interfaces:
EnvCleanup, java.io.Serializable

public class CurlResource
extends ResourceValue

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.caucho.quercus.env.Value
NULL_ARGS, NULL_VALUE_ARRAY, SCALAR_V
 
Constructor Summary
CurlResource()
           
 
Method Summary
 CurlResource clone()
          Returns a copy of this resource.
 void close()
          By default close() will call cleanup().
 Value execute(Env env)
          Executes this request.
 Value getBody()
          Returns body of last transfer.
 int getConnectTimeout()
          Returns the max time until timeout while establishing a connection.
 int getContentLength()
          Returns the length of the body from the last request.
 java.lang.String getContentType()
          Returns the "Content-Type" header from the last request.
 java.lang.String getError()
          Returns the error string from the last request.
 int getErrorCode()
          Sets the error code from the last request.
 Value getHeader()
          Returns the header from the last request.
 Callable getHeaderCallback()
           
 boolean getIsFollowingRedirects()
          Returns true if automatically following redirects.
 boolean getIsProxying()
          Returns true if a proxy is to be used.
 boolean getIsVerbose()
          Returns the verbosity of this library.
 boolean getIsVerifySSLCommonName()
           
 boolean getIsVerifySSLHostname()
           
 boolean getIsVerifySSLPeer()
           
 java.lang.String getPassword()
          Returns the password to use for authentication.
 int getPort()
          Returns the port to use for this request.
 Value getPostBody()
          Gets the body to POST to the server.
 java.lang.String getProxyPassword()
          Returns the password to use for proxy authentication.
 int getProxyPort()
          Returns the port to use for the proxy.
 java.lang.String getProxyType()
          Returns of type of the proxy (Http or SOCKS).
 java.lang.String getProxyURL()
          Returns the URL of the proxy.
 java.lang.String getProxyUsername()
          Returns the username to use for proxy authentication.
 Callable getReadCallback()
           
 int getReadTimeout()
          Returns the max time until timeout while reading body.
 java.lang.String getRequestMethod()
          Returns the current request method.
 Value getRequestProperties(Env env)
          Returns all the request properties as a String.
 java.util.HashMap<java.lang.String,java.lang.String> getRequestPropertiesMap()
          Returns a map of all the request properties.
 int getResponseCode()
          Returns the response code for the last request.
 BinaryInput getUploadFile()
          Returns handle of file to upload.
 int getUploadFileSize()
          Returns size of file to upload.
 java.lang.String getURL()
          Gets the URL to use for this request.
 java.lang.String getUsername()
          Gets the username to use for authentication.
protected  boolean hasError()
          Returns true if an error occuring during the last operation.
 boolean isResource()
           
 void removeRequestProperty(java.lang.String key)
          Remove a request property.
 void setBody(StringValue body)
          Sets the body of the last request.
 void setConnectTimeout(int timeout)
          Sets the max time until timeout while establishing a connection.
 void setContentLength(int length)
          Sets the length of the body from the last request.
 void setContentType(java.lang.String type)
          Sets the "Content-Type" from the last request.
 void setCookie(java.lang.String cookie)
          Sets the "Set-Cookie" request property.
 void setCookieFilename(java.lang.String filename)
          Sets the filename to save the cookies from the last request.
 void setError(java.lang.String error)
          Sets the error string from the last request.
 void setErrorCode(int code)
          Returns the error code from the last request.
 void setFailOnError(boolean failOnError)
          Set to true to fail on response codes >= 400.
 void setHeader(StringValue header)
          Saves the header that was returned by the server.
 void setHeaderCallback(Callable callback)
          Sets the callback to read the header.
 void setIfModifiedSince(boolean option)
          Set to true to set the If-Modified-Since property.
 void setIsFollowingRedirects(boolean followRedirects)
          Set to true to automatically follow redirects.
 void setIsProxying(boolean proxy)
          Set to true to proxy request.
 void setIsReturningBody(boolean returnBody)
          Set to true to return body for this request.
 void setIsReturningData(boolean returnData)
          Set to true to return data instead of to stdout.
 void setIsReturningHeader(boolean returnHeader)
          Set to true to return the body from this request.
 void setIsVerbose(boolean verbose)
          Sets the verbosity of this library.
 void setIsVerifySSLCommonName(boolean isVerify)
           
 void setIsVerifySSLHostname(boolean isVerify)
           
 void setIsVerifySSLPeer(boolean isVerify)
           
 void setModifiedTime(java.lang.String time)
          Sets the modified time request property.
 void setOutputFile(BinaryOutput file)
          Sets the file to save the data to save from a request.
 void setOutputHeaderFile(BinaryOutput file)
          Sets the file to save the header from a request.
 void setPassword(java.lang.String pwd)
          Sets the password to use for authentication.
 void setPasswordCallback(Callable callback)
           
 void setPort(int port)
          Sets the port to use for this request.
 void setPostBody(Value body)
          Sets the body to POST to the server.
 void setProxyPassword(java.lang.String pass)
          Sets the password to use for proxy authentication.
 void setProxyPort(int port)
          Sets the port to use for the proxy.
 void setProxyType(java.lang.String type)
          Sets the type of the proxy (Http or SOCKS).
 void setProxyURL(java.lang.String proxy)
          Sets the URL of the proxy.
 void setProxyUsername(java.lang.String user)
          Sets the username to use for proxy authentication.
 void setReadCallback(Callable callback)
          Sets the callback to read the body.
 void setReadTimeout(int timeout)
          Sets the max time until timeout while reading body.
 void setRequestMethod(java.lang.String method)
          Sets the request method to use for this request.
 void setRequestProperty(java.lang.String key, java.lang.String value)
          Sets a request property to use for this request.
 void setResponseCode(int code)
          Sets the response code for the last request.
 void setUploadFile(BinaryInput file)
          Sets handle of file to upload.
 void setUploadFileSize(int size)
          Sets size of file to upload.
 void setURL(java.lang.String url)
          Sets the URL to use for this request.
 void setUsername(java.lang.String user)
          Sets the username to use for authentication.
 void setWriteCallback(Callable callback)
           
 java.lang.String toString()
          Converts to a string.
 
Methods inherited from class com.caucho.quercus.env.ResourceValue
cleanup, printRImpl, toKey, varDumpImpl
 
Methods inherited from class com.caucho.quercus.env.Value
abs, add, add, addOne, append, appendTo, appendTo, appendTo, appendTo, bitAnd, bitOr, bitXor, call, call, call, call, call, call, call, callCopy, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callMethodRef, callRef, callRef, callRef, callRef, callRef, callRef, callRef, charValueAt, checkPrivate, checkProtected, clone, cmp, containsKey, copy, copy, copy, copyArrayItem, copyReturn, copySaveFunArg, copyStringBuilder, copyTree, current, div, div, end, eq, eql, eqValue, findFunction, generate, geq, get, getArg, getArray, getArray, getBaseIterator, getCallableName, getCalledClass, getClassName, getCount, getCountRecursive, getDirty, getField, getFieldArg, getFieldArgRef, getFieldArray, getFieldObject, getFieldVar, getHashCode, getIterator, getKeyArray, getKeyIterator, getObject, getObject, getQuercusClass, getRef, getResourceType, getSize, getThisField, getThisFieldArg, getThisFieldArgRef, getThisFieldArray, getThisFieldObject, getThisFieldVar, getType, getValueArray, getValueIterator, getValueType, getVar, gt, hasCurrent, hashCode, increment, initField, isA, isA, isArray, isBinary, isBoolean, isCallable, isDefault, isDouble, isDoubleConvertible, isEmpty, isFieldInit, isLong, isLongConvertible, isNull, isNumberConvertible, isNumeric, isObject, isset, isset, issetField, issetThisField, isString, isUnicode, isVar, jsonEncode, key, keyExists, length, leq, lshift, lt, mod, mul, mul, neg, next, nextIndex, pop, pos, postdecr, postincr, postincr, predecr, preincr, preincr, prev, print, print, printDepth, printJavaChar, printJavaString, printR, put, put, put, putField, putField, putField, putObject, putThisField, putThisField, putVar, remove, reset, rshift, serialize, serialize, set, setCharValueAt, setFieldInit, setJavaObject, shuffle, sub_rev, sub, sub, subOne, toArgRef, toArray, toArrayValue, toAutoArray, toAutoObject, toBigDecimal, toBigInteger, toBinaryValue, toBinaryValue, toBinaryValue, toBinaryValueMarshalCost, toBoolean, toBooleanMarshalCost, toByteArrayMarshalCost, toByteMarshalCost, toCallable, toChar, toCharArrayMarshalCost, toCharMarshalCost, toDebugString, toDouble, toDoubleMarshalCost, toDoubleValue, toException, toFloatMarshalCost, toInputStream, toInt, toIntegerMarshalCost, toInternString, toJavaBoolean, toJavaByte, toJavaCalendar, toJavaCharacter, toJavaCollection, toJavaDate, toJavaDouble, toJavaFloat, toJavaInteger, toJavaList, toJavaLong, toJavaMap, toJavaObject, toJavaObject, toJavaObjectMarshalCost, toJavaObjectNotNull, toJavaShort, toJavaString, toJavaURL, toLocalRef, toLocalThis, toLocalValue, toLocalValueReadOnly, toLocalVar, toLocalVarDeclAsRef, toLong, toLongMarshalCost, toLongValue, toObject, toRef, toRefValue, toShortMarshalCost, toString, toStringBuilder, toStringBuilder, toStringBuilder, toStringBuilder, toStringMarshalCost, toStringValue, toStringValue, toStringValueMarshalCost, toUnicode, toUnicodeValue, toUnicodeValue, toUnicodeValueMarshalCost, toValue, toVar, unsetArray, unsetField, unsetThisArray, unsetThisField, valuesToArray, varDump, varExport
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CurlResource

public CurlResource()
Method Detail

getBody

public Value getBody()
Returns body of last transfer.


setBody

public void setBody(StringValue body)
Sets the body of the last request.


getConnectTimeout

public int getConnectTimeout()
Returns the max time until timeout while establishing a connection.


setConnectTimeout

public void setConnectTimeout(int timeout)
Sets the max time until timeout while establishing a connection.


getContentLength

public int getContentLength()
Returns the length of the body from the last request.


setContentLength

public void setContentLength(int length)
Sets the length of the body from the last request.


getContentType

public java.lang.String getContentType()
Returns the "Content-Type" header from the last request.


setContentType

public void setContentType(java.lang.String type)
Sets the "Content-Type" from the last request.


setCookie

public void setCookie(java.lang.String cookie)
Sets the "Set-Cookie" request property.


setCookieFilename

public void setCookieFilename(java.lang.String filename)
Sets the filename to save the cookies from the last request.


getError

public java.lang.String getError()
Returns the error string from the last request.


setError

public void setError(java.lang.String error)
Sets the error string from the last request.


getErrorCode

public int getErrorCode()
Sets the error code from the last request.


setErrorCode

public void setErrorCode(int code)
Returns the error code from the last request.


setFailOnError

public void setFailOnError(boolean failOnError)
Set to true to fail on response codes >= 400.


getHeader

public Value getHeader()
Returns the header from the last request.


setHeader

public void setHeader(StringValue header)
Saves the header that was returned by the server.


getHeaderCallback

public Callable getHeaderCallback()

setHeaderCallback

public void setHeaderCallback(Callable callback)
Sets the callback to read the header.


setIfModifiedSince

public void setIfModifiedSince(boolean option)
Set to true to set the If-Modified-Since property. Time to use is set with setModifiedTime().


getIsFollowingRedirects

public boolean getIsFollowingRedirects()
Returns true if automatically following redirects.


setIsFollowingRedirects

public void setIsFollowingRedirects(boolean followRedirects)
Set to true to automatically follow redirects.


getIsProxying

public boolean getIsProxying()
Returns true if a proxy is to be used.


setIsProxying

public void setIsProxying(boolean proxy)
Set to true to proxy request.


setIsReturningBody

public void setIsReturningBody(boolean returnBody)
Set to true to return body for this request.


setIsReturningData

public void setIsReturningData(boolean returnData)
Set to true to return data instead of to stdout.


setIsReturningHeader

public void setIsReturningHeader(boolean returnHeader)
Set to true to return the body from this request.


getIsVerbose

public boolean getIsVerbose()
Returns the verbosity of this library.


setIsVerbose

public void setIsVerbose(boolean verbose)
Sets the verbosity of this library.


getIsVerifySSLPeer

public boolean getIsVerifySSLPeer()

setIsVerifySSLPeer

public void setIsVerifySSLPeer(boolean isVerify)

getIsVerifySSLCommonName

public boolean getIsVerifySSLCommonName()

setIsVerifySSLCommonName

public void setIsVerifySSLCommonName(boolean isVerify)

getIsVerifySSLHostname

public boolean getIsVerifySSLHostname()

setIsVerifySSLHostname

public void setIsVerifySSLHostname(boolean isVerify)

setModifiedTime

public void setModifiedTime(java.lang.String time)
Sets the modified time request property.


setOutputFile

public void setOutputFile(BinaryOutput file)
Sets the file to save the data to save from a request.


setOutputHeaderFile

public void setOutputHeaderFile(BinaryOutput file)
Sets the file to save the header from a request.


getPassword

public java.lang.String getPassword()
Returns the password to use for authentication.


setPassword

public void setPassword(java.lang.String pwd)
Sets the password to use for authentication.


setPasswordCallback

public void setPasswordCallback(Callable callback)

getPort

public int getPort()
Returns the port to use for this request.


setPort

public void setPort(int port)
Sets the port to use for this request.


getPostBody

public Value getPostBody()
Gets the body to POST to the server.


setPostBody

public void setPostBody(Value body)
Sets the body to POST to the server.


getProxyPassword

public java.lang.String getProxyPassword()
Returns the password to use for proxy authentication.


setProxyPassword

public void setProxyPassword(java.lang.String pass)
Sets the password to use for proxy authentication.


getProxyPort

public int getProxyPort()
Returns the port to use for the proxy.


setProxyPort

public void setProxyPort(int port)
Sets the port to use for the proxy.


getProxyType

public java.lang.String getProxyType()
Returns of type of the proxy (Http or SOCKS).


setProxyType

public void setProxyType(java.lang.String type)
Sets the type of the proxy (Http or SOCKS).


getProxyURL

public java.lang.String getProxyURL()
Returns the URL of the proxy.


setProxyURL

public void setProxyURL(java.lang.String proxy)
Sets the URL of the proxy.


getProxyUsername

public java.lang.String getProxyUsername()
Returns the username to use for proxy authentication.


setProxyUsername

public void setProxyUsername(java.lang.String user)
Sets the username to use for proxy authentication.


getReadCallback

public Callable getReadCallback()

setReadCallback

public void setReadCallback(Callable callback)
Sets the callback to read the body.


getReadTimeout

public int getReadTimeout()
Returns the max time until timeout while reading body.


setReadTimeout

public void setReadTimeout(int timeout)
Sets the max time until timeout while reading body.


getRequestMethod

public java.lang.String getRequestMethod()
Returns the current request method.


setRequestMethod

public void setRequestMethod(java.lang.String method)
Sets the request method to use for this request.


getRequestPropertiesMap

public java.util.HashMap<java.lang.String,java.lang.String> getRequestPropertiesMap()
Returns a map of all the request properties.


getRequestProperties

public Value getRequestProperties(Env env)
Returns all the request properties as a String.


setRequestProperty

public void setRequestProperty(java.lang.String key,
                               java.lang.String value)
Sets a request property to use for this request.


getResponseCode

public int getResponseCode()
Returns the response code for the last request.


setResponseCode

public void setResponseCode(int code)
Sets the response code for the last request.


getUploadFile

public BinaryInput getUploadFile()
Returns handle of file to upload.


setUploadFile

public void setUploadFile(BinaryInput file)
Sets handle of file to upload.


getUploadFileSize

public int getUploadFileSize()
Returns size of file to upload.


setUploadFileSize

public void setUploadFileSize(int size)
Sets size of file to upload.


getURL

public java.lang.String getURL()
Gets the URL to use for this request.


setURL

public void setURL(java.lang.String url)
Sets the URL to use for this request.


getUsername

public java.lang.String getUsername()
Gets the username to use for authentication.


setUsername

public void setUsername(java.lang.String user)
Sets the username to use for authentication.


setWriteCallback

public void setWriteCallback(Callable callback)

removeRequestProperty

public void removeRequestProperty(java.lang.String key)
Remove a request property.


execute

public Value execute(Env env)
Executes this request.


close

public void close()
Description copied from class: ResourceValue
By default close() will call cleanup(). If implementation specific logic is needed to clean up resources it should be defined in an overloaded cleanup().

Overrides:
close in class ResourceValue

hasError

protected boolean hasError()
Returns true if an error occuring during the last operation.


clone

public CurlResource clone()
Returns a copy of this resource.

Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Description copied from class: ResourceValue
Converts to a string.

Overrides:
toString in class ResourceValue

isResource

public boolean isResource()
Overrides:
isResource in class Value