47 #define HTTP_CONN_EXPIRY ( 10 * TICKS_PER_SEC ) 50 static LIST_HEAD ( http_connection_pool );
103 DBGC2 ( conn,
"HTTPCONN %p closed %s://%s\n",
106 DBGC ( conn,
"HTTPCONN %p closed %s://%s: %s\n",
138 pool_alive ( &conn->
pool );
157 if ( pool_is_reopenable ( &conn->
pool ) )
172 pool_recyclable ( &conn->
pool );
173 DBGC2 ( conn,
"HTTPCONN %p keepalive enabled\n", conn );
187 if ( (
rc == 0 ) && pool_is_recyclable ( &conn->
pool ) ) {
191 DBGC2 ( conn,
"HTTPCONN %p pooled %s://%s\n",
268 if ( ( scheme == conn->
scheme ) &&
277 DBGC2 ( conn,
"HTTPCONN %p reused %s://%s:%d\n", conn,
284 conn =
zalloc (
sizeof ( *conn ) );
297 memset ( &server, 0,
sizeof ( server ) );
305 if ( scheme->
filter && ( (
rc = scheme->
filter ( conn ) ) != 0 ) )
312 DBGC2 ( conn,
"HTTPCONN %p created %s://%s:%d\n", conn,
318 DBGC2 ( conn,
"HTTPCONN %p could not create %s://%s:%d: %s\n", conn,
static struct interface_operation http_conn_socket_operations[]
HTTP connection socket interface operations.
#define EINVAL
Invalid argument.
An object interface operation.
struct refcnt refcnt
Reference count.
struct arbelprm_rc_send_wqe rc
void pool_add(struct pooled_connection *pool, struct list_head *list, unsigned long expiry)
Add connection to pool.
void intf_close(struct interface *intf, int rc)
Close an object interface.
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
static void uri_put(struct uri *uri)
Decrement URI reference count.
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
static struct interface_descriptor http_conn_socket_desc
HTTP connection socket interface descriptor.
#define ref_init(refcnt, free)
Initialise a reference counter.
unsigned int port
Default port.
int(* filter)(struct http_connection *conn)
Transport-layer filter (if any)
static struct interface_operation http_conn_xfer_operations[]
HTTP connection data transfer interface operations.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
int strcasecmp(const char *first, const char *second)
Compare case-insensitive strings.
struct interface socket
Transport layer interface.
Uniform Resource Identifiers.
void pool_del(struct pooled_connection *pool)
Remove connection from pool.
#define ENOTSUP
Operation not supported.
struct interface xfer
Data transfer interface.
Data transfer interfaces.
int http_connect(struct interface *xfer, struct uri *uri)
Connect to an HTTP server.
#define ENOMEM
Not enough space.
const char * scheme
Scheme.
static struct http_scheme * http_scheme(struct uri *uri)
Identify HTTP scheme.
Hyper Text Transport Protocol.
static int http_conn_socket_deliver(struct http_connection *conn, struct io_buffer *iobuf, struct xfer_metadata *meta)
Receive data from transport layer interface.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
static void http_conn_socket_close(struct http_connection *conn, int rc)
Close HTTP connection transport layer interface.
#define list_for_each_entry_reverse(pos, head, member)
Iterate over entries in a list in reverse order.
Transport-network layer interface.
void pool_reopen(struct interface *intf)
Reopen a defunct connection.
static void http_conn_xfer_close(struct http_connection *conn, int rc)
Close HTTP connection data transfer interface.
const char * name
Scheme name (e.g.
uint16_t st_port
TCP/IP port.
Generalized socket address structure.
An object interface descriptor.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
static void http_conn_close(struct http_connection *conn, int rc)
Close HTTP connection.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Data transfer interface opening.
const char * host
Host name.
struct http_scheme * scheme
HTTP scheme.
#define HTTP_SCHEMES
HTTP scheme table.
#define HTTP_CONN_EXPIRY
HTTP pooled connection expiry time.
int strcmp(const char *first, const char *second)
Compare strings.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct uri * uri
Connection URI.
static void http_conn_free(struct refcnt *refcnt)
Free HTTP connection.
unsigned int uri_port(const struct uri *uri, unsigned int default_port)
Get port from URI.
A Uniform Resource Identifier.
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
static void http_conn_expired(struct pooled_connection *pool)
Disconnect idle HTTP connection.
void pool_recycle(struct interface *intf)
Recycle this connection after closing.
static void http_conn_xfer_recycle(struct http_connection *conn)
Recycle this connection after closing.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
struct pooled_connection pool
Pooled connection.
#define NULL
NULL pointer (VOID *)
static LIST_HEAD(http_connection_pool)
HTTP connection pool.
int xfer_open_named_socket(struct interface *xfer, int semantics, struct sockaddr *peer, const char *name, struct sockaddr *local)
Open named socket.
#define ref_put(refcnt)
Drop reference to object.
void * memset(void *dest, int character, size_t len) __nonnull
static struct interface_descriptor http_conn_xfer_desc
HTTP connection data transfer interface descriptor.