Overview

Namespaces

  • Budabot
    • Core
      • Modules
    • User
      • Modules
  • None
  • Tyrence
    • Modules

Classes

  • AccessManager
  • AdminManager
  • AOChat
  • AOChatPacket
  • AOChatQueue
  • AOExtMsg
  • AsyncHttp
  • AutoInject
  • BotRunner
  • Budabot
  • BuddylistManager
  • CacheManager
  • CacheResult
  • ClassLoader
  • ColorSettingHandler
  • CommandAlias
  • CommandManager
  • ConfigFile
  • DB
  • DBRow
  • EventLoop
  • EventManager
  • GuildChannelCommandReply
  • GuildManager
  • HelpManager
  • Http
  • HttpRequest
  • LegacyLogger
  • LimitsController
  • LoggerWrapper
  • MMDBParser
  • NumberSettingHandler
  • OptionsSettingHandler
  • PlayerHistory
  • PlayerHistoryManager
  • PlayerManager
  • Preferences
  • PrivateChannelCommandReply
  • PrivateMessageCommandReply
  • Registry
  • SettingHandler
  • SettingManager
  • SettingObject
  • SocketManager
  • SocketNotifier
  • SubcommandManager
  • Text
  • TextSettingHandler
  • Timer
  • TimerEvent
  • TimeSettingHandler
  • Util
  • xml

Interfaces

  • CommandReply

Exceptions

  • InvalidHttpRequest
  • SQLException
  • StopExecutionException

Functions

  • isWindows
  • Overview
  • Namespace
  • Class

Class AsyncHttp

The AsyncHttp class provides means to make HTTP and HTTPS requests.

This class should not be instanced as it is, but instead Http class's get() or post() method should be used to create instance of the AsyncHttp class.

Namespace: Budabot\Core
Located at AsyncHttp.class.php
Methods summary
public
# execute( )
private
# buildRequest( )
private
# setError( string $errorString )

Sets error to given $errorString.

Sets error to given $errorString.

Parameters

$errorString
error string
private
# finish( )
private
# close( )

Removes socket notifier from bot's reactor loop and closes the stream.

Removes socket notifier from bot's reactor loop and closes the stream.

private
# callCallback( )

Calls the user supplied callback.

Calls the user supplied callback.

private
# buildResponse( )
private
# initTimeout( )
private
# createStream( )
private
# getStreamUri( )
private
# getStreamFlags( )
private
# setupStreamNotify( )
public
# onStreamActivity( integer $type )

Parameters

$type
type of activity, see SocketNotifier::ACTIVITY_* constants.
private
# processResponse( )
private
# processHeaders( )
private
# getResponseBody( )
private
# areHeadersReceived( )
private
# isStreamClosed( )
private
# isBodyFullyReceived( )
private
# isBodyLengthKnown( )
private
# readAllFromSocket( )
private
# getBodyLength( )
private
# extractHeadersFromHeaderData( $data )
private
# processRequest( )
public Budabot\Core\AsyncHttp
# withHeader( $header, $value )

Parameters

$header
$value

Returns

Budabot\Core\AsyncHttp
public Budabot\Core\AsyncHttp
# withTimeout( $timeout )

Parameters

$timeout

Returns

Budabot\Core\AsyncHttp
public Budabot\Core\AsyncHttp
# withCallback( callable $callback, mixed $data = null )

Defines a callback which will be called later on when the remote server has responded or an error has occurred.

Defines a callback which will be called later on when the remote server has responded or an error has occurred.

The callback has following signature:

function callback($response, $data)
  • $response - Response as an object, it has properties: $error: error message, if any $headers: received HTTP headers as an array $body: received contents * $data - optional value which is same as given as argument to this method.

Parameters

$callback
callback which will be called when request is done
$data
extra data which will be passed as second argument to the callback

Returns

Budabot\Core\AsyncHttp
public Budabot\Core\AsyncHttp
# withQueryParams( array $params )

Parameters

$params
array of key/value pair parameters passed as a query

Returns

Budabot\Core\AsyncHttp
public mixed
# waitAndReturnResponse( )

Waits until response is fully received from remote server and returns the response. Note that this blocks execution, but does not freeze the bot as the execution will return to event loop while waiting.

Waits until response is fully received from remote server and returns the response. Note that this blocks execution, but does not freeze the bot as the execution will return to event loop while waiting.

Returns

mixed
Properties summary
public $setting

Inject

#
public $socketManager

Inject

#
public $timer

Inject

#
public $logger

Logger

#
private $uri
#
private $callback
#
private $data
#
private array $headers
# array()
private $timeout
# null
private array $queryParams
# array()
private $stream
#
private $notifier
#
private string $requestData
# ''
private string $responseData
# ''
private boolean $headersEndPos
# false
private array $responseHeaders
# array()
private $request
#
private boolean $errorString
# false
private $timeoutEvent
# null
private $finished
#
private $loop
#
Budabot 4 Docs API documentation generated by ApiGen