Cisco Packet Tracer Extensions API 8.1.0
API for communication between Cisco Packet Tracer application and its extension applications and modules.
Public Member Functions | List of all members
HttpServer Class Reference

HttpServer handles and manipulates the HTTP server on devices. More...

Inheritance diagram for HttpServer:
Process HttpsServer

Public Member Functions

void setPortNumber (short)
 Sets the port number of the HTTP service. More...
 
short getPortNumber ()
 Returns the port number of the HTTP service. More...
 
void setEnable (bool)
 Enables or disables the HTTP service. More...
 
bool isEnabled ()
 Returns true if the HTTP service is enabled, otherwise false. More...
 
string getPage (string)
 Returns the page contents at the specified URL. More...
 
void setPageContents (string, string)
 Sets the page contents at the specified URL. More...
 
string getUsername ()
 Returns the htaccess username for the HTTP server. More...
 
string getPassword ()
 Returns the htaccess password for the HTTP server. More...
 
void setUsername (string)
 Sets the htaccess username for the HTTP server. More...
 
void setPassword (string)
 Sets the htaccess password for the HTTP server. More...
 
void sendResponse (TcpConnection, string)
 send the HTTP response back to client with given content. More...
 
void sendTypedResponse (TcpConnection, string, string)
 send the HTTP response back to client with given content and content type. More...
 
void sendFileResponse (TcpConnection, string)
 send the HTTP response back to client with given file. More...
 
void sendNotFoundResponse (TcpConnection)
 send the 404 not found HTTP response back to client with given file. More...
 
bool onRequest (string, TcpConnection)
 This delegate pass the url and tcp connection on HTTP request and returns true if successful, otherwise false. More...
 
- Public Member Functions inherited from Process
Device getOwnerDevice ()
 Returns the device for this process. More...
 

Detailed Description

HttpServer handles and manipulates the HTTP server on devices.

Member Function Documentation

◆ getPage()

string HttpServer::getPage ( string  )

Returns the page contents at the specified URL.

Parameters
url,theURL of the page of interest.
Returns
string, the page contents at the specified URL.

◆ getPassword()

string HttpServer::getPassword ( )

Returns the htaccess password for the HTTP server.

Returns
string, the htaccess password for the HTTP server.

◆ getPortNumber()

short HttpServer::getPortNumber ( )

Returns the port number of the HTTP service.

Returns
int, the port number of the HTTP service.

◆ getUsername()

string HttpServer::getUsername ( )

Returns the htaccess username for the HTTP server.

Returns
string, the htaccess username for the HTTP server.

◆ isEnabled()

bool HttpServer::isEnabled ( )

Returns true if the HTTP service is enabled, otherwise false.

Returns
bool, true if the HTTP service is enabled, otherwise false.

◆ onRequest()

bool HttpServer::onRequest ( string  ,
TcpConnection   
)

This delegate pass the url and tcp connection on HTTP request and returns true if successful, otherwise false.

  • url, the url of the HTTP connection.
  • connection, connection, the Tcp connection of the HTTP connection.
Returns
bool, true if successful, otherwise false.

◆ sendFileResponse()

void HttpServer::sendFileResponse ( TcpConnection  ,
string   
)

send the HTTP response back to client with given file.

Parameters
connection,theTcp connection of the HTTP response.
filePath,thefile get send in the HTTP response.

◆ sendNotFoundResponse()

void HttpServer::sendNotFoundResponse ( TcpConnection  )

send the 404 not found HTTP response back to client with given file.

Parameters
connection,theTcp connection of the HTTP response.

◆ sendResponse()

void HttpServer::sendResponse ( TcpConnection  ,
string   
)

send the HTTP response back to client with given content.

Parameters
connection,theTcp connection of the HTTP response.
content,thecontent of the HTTP response.

◆ sendTypedResponse()

void HttpServer::sendTypedResponse ( TcpConnection  ,
string  ,
string   
)

send the HTTP response back to client with given content and content type.

Parameters
connection,theTcp connection of the HTTP response.
content,thecontent of the HTTP response.
contentType,thecontentType of the HTTP response.

◆ setEnable()

void HttpServer::setEnable ( bool  )

Enables or disables the HTTP service.

Parameters
bEnable,trueto enable the HTTP service, false to disable it.

◆ setPageContents()

void HttpServer::setPageContents ( string  ,
string   
)

Sets the page contents at the specified URL.

Parameters
url,theURL of the page of interest.
contents,thecontents of the page of interest.

◆ setPassword()

void HttpServer::setPassword ( string  )

Sets the htaccess password for the HTTP server.

Parameters
password,thehtaccess password for the HTTP server.

◆ setPortNumber()

void HttpServer::setPortNumber ( short  )

Sets the port number of the HTTP service.

Parameters
num,theport number to set the HTTP service to.

◆ setUsername()

void HttpServer::setUsername ( string  )

Sets the htaccess username for the HTTP server.

Parameters
username,thehtaccess username for the HTTP server.

The documentation for this class was generated from the following file: