|
Packit |
875988 |
/*
|
|
Packit |
875988 |
This file is part of libmicrohttpd
|
|
Packit |
875988 |
Copyright (C) 2007 Daniel Pittman and Christian Grothoff
|
|
Packit |
875988 |
|
|
Packit |
875988 |
This library is free software; you can redistribute it and/or
|
|
Packit |
875988 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
875988 |
License as published by the Free Software Foundation; either
|
|
Packit |
875988 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
875988 |
|
|
Packit |
875988 |
This library is distributed in the hope that it will be useful,
|
|
Packit |
875988 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
875988 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
875988 |
Lesser General Public License for more details.
|
|
Packit |
875988 |
|
|
Packit |
875988 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
875988 |
License along with this library; if not, write to the Free Software
|
|
Packit |
875988 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* @file connection.h
|
|
Packit |
875988 |
* @brief Methods for managing connections
|
|
Packit |
875988 |
* @author Daniel Pittman
|
|
Packit |
875988 |
* @author Christian Grothoff
|
|
Packit |
875988 |
* @author Karlson2k (Evgeny Grin)
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#ifndef CONNECTION_H
|
|
Packit |
875988 |
#define CONNECTION_H
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#include "internal.h"
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Error code similar to EGAIN or EINTR
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
#define MHD_ERR_AGAIN_ (-3073)
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Connection was hard-closed by remote peer.
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
#define MHD_ERR_CONNRESET_ (-3074)
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Connection is not connected anymore due to
|
|
Packit |
875988 |
* network error or any other reason.
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
#define MHD_ERR_NOTCONN_ (-3075)
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* "Not enough memory" error code
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
#define MHD_ERR_NOMEM_ (-3076)
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* "Bad FD" error code
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
#define MHD_ERR_BADF_ (-3077)
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Error code similar to EINVAL
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
#define MHD_ERR_INVAL_ (-3078)
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#ifdef HAVE_FREEBSD_SENDFILE
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Initialises static variables
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
void
|
|
Packit |
875988 |
MHD_conn_init_static_ (void);
|
|
Packit |
875988 |
#endif /* HAVE_FREEBSD_SENDFILE */
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Set callbacks for this connection to those for HTTP.
|
|
Packit |
875988 |
*
|
|
Packit |
875988 |
* @param connection connection to initialize
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
void
|
|
Packit |
875988 |
MHD_set_http_callbacks_ (struct MHD_Connection *connection);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* This function handles a particular connection when it has been
|
|
Packit |
875988 |
* determined that there is data to be read off a socket. All
|
|
Packit |
875988 |
* implementations (multithreaded, external select, internal select)
|
|
Packit |
875988 |
* call this function to handle reads.
|
|
Packit |
875988 |
*
|
|
Packit |
875988 |
* @param connection connection to handle
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
void
|
|
Packit |
875988 |
MHD_connection_handle_read (struct MHD_Connection *connection);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* This function was created to handle writes to sockets when it has
|
|
Packit |
875988 |
* been determined that the socket can be written to. All
|
|
Packit |
875988 |
* implementations (multithreaded, external select, internal select)
|
|
Packit |
875988 |
* call this function
|
|
Packit |
875988 |
*
|
|
Packit |
875988 |
* @param connection connection to handle
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
void
|
|
Packit |
875988 |
MHD_connection_handle_write (struct MHD_Connection *connection);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* This function was created to handle per-connection processing that
|
|
Packit |
875988 |
* has to happen even if the socket cannot be read or written to. All
|
|
Packit |
875988 |
* implementations (multithreaded, external select, internal select)
|
|
Packit |
875988 |
* call this function.
|
|
Packit |
875988 |
* @remark To be called only from thread that process connection's
|
|
Packit |
875988 |
* recv(), send() and response.
|
|
Packit |
875988 |
*
|
|
Packit |
875988 |
* @param connection connection to handle
|
|
Packit |
875988 |
* @return MHD_YES if we should continue to process the
|
|
Packit |
875988 |
* connection (not dead yet), MHD_NO if it died
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
MHD_connection_handle_idle (struct MHD_Connection *connection);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Mark connection as "closed".
|
|
Packit |
875988 |
* @remark To be called from any thread.
|
|
Packit |
875988 |
*
|
|
Packit |
875988 |
* @param connection connection to close
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
void
|
|
Packit |
875988 |
MHD_connection_mark_closed_ (struct MHD_Connection *connection);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Close the given connection and give the
|
|
Packit |
875988 |
* specified termination code to the user.
|
|
Packit |
875988 |
* @remark To be called only from thread that
|
|
Packit |
875988 |
* process connection's recv(), send() and response.
|
|
Packit |
875988 |
*
|
|
Packit |
875988 |
* @param connection connection to close
|
|
Packit |
875988 |
* @param termination_code termination reason to give
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
void
|
|
Packit |
875988 |
MHD_connection_close_ (struct MHD_Connection *connection,
|
|
Packit |
875988 |
enum MHD_RequestTerminationCode termination_code);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#ifdef HTTPS_SUPPORT
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Stop TLS forwarding on upgraded connection and
|
|
Packit |
875988 |
* reflect remote disconnect state to socketpair.
|
|
Packit |
875988 |
* @param connection the upgraded connection
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
void
|
|
Packit |
875988 |
MHD_connection_finish_forward_ (struct MHD_Connection *connection);
|
|
Packit |
875988 |
#else /* ! HTTPS_SUPPORT */
|
|
Packit |
875988 |
#define MHD_connection_finish_forward_(conn) (void)conn
|
|
Packit |
875988 |
#endif /* ! HTTPS_SUPPORT */
|
|
Packit |
875988 |
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#ifdef EPOLL_SUPPORT
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Perform epoll processing, possibly moving the connection back into
|
|
Packit |
875988 |
* the epoll set if needed.
|
|
Packit |
875988 |
*
|
|
Packit |
875988 |
* @param connection connection to process
|
|
Packit |
875988 |
* @return MHD_YES if we should continue to process the
|
|
Packit |
875988 |
* connection (not dead yet), MHD_NO if it died
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
int
|
|
Packit |
875988 |
MHD_connection_epoll_update_ (struct MHD_Connection *connection);
|
|
Packit |
875988 |
#endif
|
|
Packit |
875988 |
|
|
Packit |
875988 |
/**
|
|
Packit |
875988 |
* Update the 'last_activity' field of the connection to the current time
|
|
Packit |
875988 |
* and move the connection to the head of the 'normal_timeout' list if
|
|
Packit |
875988 |
* the timeout for the connection uses the default value.
|
|
Packit |
875988 |
*
|
|
Packit |
875988 |
* @param connection the connection that saw some activity
|
|
Packit |
875988 |
*/
|
|
Packit |
875988 |
void
|
|
Packit |
875988 |
MHD_update_last_activity_ (struct MHD_Connection *connection);
|
|
Packit |
875988 |
|
|
Packit |
875988 |
#endif
|