aboutsummaryrefslogtreecommitdiff
path: root/src/include/microhttpd.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/microhttpd.h')
-rw-r--r--src/include/microhttpd.h113
1 files changed, 92 insertions, 21 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 442c51f0..3f488538 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -1418,16 +1418,82 @@ MHD_create_response_from_fd_at_offset (size_t size,
1418 off_t offset); 1418 off_t offset);
1419 1419
1420 1420
1421#if 0
1422/**
1423 * Bits in an event mask that specifies which actions
1424 * MHD should perform and under which conditions it
1425 * should call the 'upgrade' callback again.
1426 */
1427enum MHD_UpgradeEventMask
1428{
1429
1430 /**
1431 * Never call the handler again; finish sending bytes
1432 * in the 'write' buffer and then close the socket.
1433 */
1434 MHD_UPGRADE_EVENT_TERMINATE = 0,
1435
1436 /**
1437 * Call the handler again once there is data ready
1438 * for reading.
1439 */
1440 MHD_UPGRADE_EVENT_READ = 1,
1441
1442 /**
1443 * Call the handler again once there is buffer space
1444 * available for writing.
1445 */
1446 MHD_UPGRADE_EVENT_WRITE = 2,
1447
1448 /**
1449 * Do not wait on any socket actions, we're waiting on
1450 * an 'external' event. Run the function again once
1451 * the 'select' call returns _without_ this socket even
1452 * being involved in the select sets (useful in
1453 * conjunction with the external select loop).
1454 */
1455 MHD_UPGRADE_EVENT_EXTERNAL = 4,
1456
1457 /**
1458 * Uncork the TCP write buffer (that is, tell the OS to transmit all
1459 * bytes in the buffer now, and to not use TCP-CORKing). This is
1460 * not really an event flag, but an additional request (which MHD
1461 * may ignore if the platform does not support it). Note that
1462 * only returning 'CORK' will *also* cause the socket to be closed!
1463 */
1464 MHD_UPGRADE_EVENT_CORK = 8
1465
1466};
1467
1468
1421/** 1469/**
1422 * Function called after a protocol upgrade response was sent 1470 * Function called after a protocol "upgrade" response was sent
1423 * successfully and the socket should now be controlled by some 1471 * successfully and the socket should now be controlled by some
1424 * protocol other than HTTP. Note that from this point on, MHD will 1472 * protocol other than HTTP.
1425 * consider this connection to be "complete", so it will no longer be 1473 *
1426 * counted as an active connection for the 1474 * Any data received on the socket will be made available in
1427 * MHD_OPTION_PER_IP_CONNECTION_LIMIT or the 1475 * 'data_in'. The function should update 'data_in_size' to
1428 * MHD_OPTION_CONNECTION_LIMIT. After this function returns, the 1476 * reflect the number of bytes consumed from 'data_in' (the remaining
1477 * bytes will be made available in the next call to the handler).
1478 *
1479 * Any data that should be transmitted on the socket should be
1480 * stored in 'data_out'. '*data_out_size' is initially set to
1481 * the available buffer space in 'data_out'. It should be set to
1482 * the number of bytes stored in 'data_out' (which can be zero).
1483 *
1484 * The return value is a BITMASK that indicates how the function
1485 * intends to interact with the event loop. It can request to be
1486 * notified for reading, writing, request to UNCORK the send buffer
1487 * (which MHD is allowed to ignore, if it is not possible to uncork on
1488 * the local platform), to wait for the 'external' select loop to
1489 * trigger another round. It is also possible to specify "no events"
1490 * to terminate the connection; in this case, the
1429 * MHD_RequestCompletedCallback will be called and all resources of 1491 * MHD_RequestCompletedCallback will be called and all resources of
1430 * the connection (except for the socket itself) will be released. 1492 * the connection will be released.
1493 *
1494 * Except when in 'thread-per-connection' mode, implementations
1495 * of this function should never block (as it will still be called
1496 * from within the main event loop).
1431 * 1497 *
1432 * @param cls closure 1498 * @param cls closure
1433 * @param connection original HTTP connection handle, 1499 * @param connection original HTTP connection handle,
@@ -1436,24 +1502,29 @@ MHD_create_response_from_fd_at_offset (size_t size,
1436 * @param con_cls value as set by the last call to the 1502 * @param con_cls value as set by the last call to the
1437 * MHD_AccessHandlerCallback; will afterwards 1503 * MHD_AccessHandlerCallback; will afterwards
1438 * be also given to the MHD_RequestCompletedCallback 1504 * be also given to the MHD_RequestCompletedCallback
1439 * @param upgrade_socket TCP socket that was upgraded from HTTP 1505 * @param data_in_size available data for reading, set to data read
1440 * to some other protocol. This function must 1506 * @param data_in data read from the socket
1441 * take over the communication and is ultimately 1507 * @param data_out_size available buffer for writing, set to bytes
1442 * responsible for closing the socket. 1508 * written to 'data_out'
1509 * @param data_out buffer for sending data via the connection
1510 * @return desired actions for event handling loop
1443 */ 1511 */
1444typedef void (*MHD_UpgradeHandler)(void *cls, 1512typedef enum MHD_UpgradeEventMask (*MHD_UpgradeHandler)(void *cls,
1445 struct MHD_Connection *connection, 1513 struct MHD_Connection *connection,
1446 void **con_cls, 1514 void **con_cls,
1447 int upgrade_socket); 1515 size_t *data_in_size,
1516 const char *data_in,
1517 size_t *data_out_size,
1518 char *data_out);
1519
1448 1520
1449#if 0
1450/** 1521/**
1451 * Create a response object that can be used for 101 UPGRADE 1522 * Create a response object that can be used for 101 UPGRADE
1452 * responses, for example to implement websockets. After sending the 1523 * responses, for example to implement websockets. After sending the
1453 * response, control over the socket is given to the callback (which 1524 * response, control over the data stream is given to the callback (which
1454 * can then, for example, start some bi-directional communication). 1525 * can then, for example, start some bi-directional communication).
1455 * If the response is queued for multiple connections, the callback 1526 * If the response is queued for multiple connections, the callback
1456 * will be called with a socket for each connection. The callback 1527 * will be called for each connection. The callback
1457 * will ONLY be called if the response header was successfully passed 1528 * will ONLY be called if the response header was successfully passed
1458 * to the OS; if there are communication errors before, the usual MHD 1529 * to the OS; if there are communication errors before, the usual MHD
1459 * connection error handling code will be performed. 1530 * connection error handling code will be performed.
@@ -1461,12 +1532,12 @@ typedef void (*MHD_UpgradeHandler)(void *cls,
1461 * Setting the correct HTTP code (i.e. MHD_HTTP_SWITCHING_PROTOCOLS) 1532 * Setting the correct HTTP code (i.e. MHD_HTTP_SWITCHING_PROTOCOLS)
1462 * and setting correct HTTP headers for the upgrade must be done 1533 * and setting correct HTTP headers for the upgrade must be done
1463 * manually (this way, it is possible to implement most existing 1534 * manually (this way, it is possible to implement most existing
1464 * WebSocket version using this API; in fact, this API might be useful 1535 * WebSocket versions using this API; in fact, this API might be useful
1465 * for any protocol switch, not just web sockets). Note that 1536 * for any protocol switch, not just websockets). Note that
1466 * draft-ietf-hybi-thewebsocketprotocol-00 cannot be implemented this 1537 * draft-ietf-hybi-thewebsocketprotocol-00 cannot be implemented this
1467 * way as the header "HTTP/1.1 101 WebSocket Protocol Handshake" 1538 * way as the header "HTTP/1.1 101 WebSocket Protocol Handshake"
1468 * cannot be generated; instead, MHD will always produce "HTTP/1.1 101 1539 * cannot be generated; instead, MHD will always produce "HTTP/1.1 101
1469 * Switching Protocols" (if the response 101 is used). 1540 * Switching Protocols" (if the response code 101 is used).
1470 * 1541 *
1471 * As usual, the response object can be extended with header 1542 * As usual, the response object can be extended with header
1472 * information and then be used any number of times (as long as the 1543 * information and then be used any number of times (as long as the