LLVM 19.0.0git
Public Member Functions | Static Public Member Functions | List of all members
llvm::HTTPServer Class Reference

An HTTP server which can listen on a single TCP/IP port for HTTP requests and delgate them to the appropriate registered handler. More...

#include "llvm/Debuginfod/HTTPServer.h"

Public Member Functions

 HTTPServer ()
 
 ~HTTPServer ()
 
Error get (StringRef UrlPathPattern, HTTPRequestHandler Handler)
 Registers a URL pattern routing rule.
 
Error bind (unsigned Port, const char *HostInterface="0.0.0.0")
 Attempts to assign the requested port and interface, returning an Error upon failure.
 
Expected< unsignedbind (const char *HostInterface="0.0.0.0")
 Attempts to assign any available port and interface, returning either the port number or an Error upon failure.
 
Error listen ()
 Attempts to listen for requests on the bound port.
 
void stop ()
 If the server is listening, stop and unbind the socket.
 

Static Public Member Functions

static bool isAvailable ()
 Returns true only if LLVM has been compiled with a working HTTPServer.
 

Detailed Description

An HTTP server which can listen on a single TCP/IP port for HTTP requests and delgate them to the appropriate registered handler.

Definition at line 99 of file HTTPServer.h.

Constructor & Destructor Documentation

◆ HTTPServer()

HTTPServer::HTTPServer ( )
default

◆ ~HTTPServer()

HTTPServer::~HTTPServer ( )
default

Member Function Documentation

◆ bind() [1/2]

Expected< unsigned > HTTPServer::bind ( const char HostInterface = "0.0.0.0")

Attempts to assign any available port and interface, returning either the port number or an Error upon failure.

Definition at line 186 of file HTTPServer.cpp.

◆ bind() [2/2]

Error HTTPServer::bind ( unsigned  Port,
const char HostInterface = "0.0.0.0" 
)

Attempts to assign the requested port and interface, returning an Error upon failure.

Definition at line 182 of file HTTPServer.cpp.

◆ get()

Error HTTPServer::get ( StringRef  UrlPathPattern,
HTTPRequestHandler  Handler 
)

Registers a URL pattern routing rule.

When the server is listening, each request is dispatched to the first registered handler whose UrlPathPattern matches the UrlPath.

Definition at line 175 of file HTTPServer.cpp.

References llvm::Error::success().

Referenced by llvm::DebuginfodServer::DebuginfodServer().

◆ isAvailable()

bool HTTPServer::isAvailable ( )
static

Returns true only if LLVM has been compiled with a working HTTPServer.

Definition at line 161 of file HTTPServer.cpp.

◆ listen()

Error HTTPServer::listen ( )

Attempts to listen for requests on the bound port.

Returns an Error if called before binding a port.

Definition at line 190 of file HTTPServer.cpp.

◆ stop()

void HTTPServer::stop ( )

If the server is listening, stop and unbind the socket.

Definition at line 194 of file HTTPServer.cpp.

References llvm_unreachable.


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