Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

http_server.c File Reference

http_server.c File Reference

HTTP server (HyperText Transfer Protocol) More...

Go to the source code of this file.

Functions

void httpServerGetDefaultSettings (HttpServerSettings *settings)
 Initialize settings with default values.
error_t httpServerInit (HttpServerContext *context, const HttpServerSettings *settings)
 HTTP server initialization.
error_t httpServerStart (HttpServerContext *context)
 Start HTTP server.
void httpListenerTask (void *param)
 HTTP server listener task.
void httpConnectionTask (void *param)
 Task that services requests from an active connection.
error_t httpWriteHeader (HttpConnection *connection)
 Send HTTP response header.
error_t httpReadStream (HttpConnection *connection, void *data, size_t size, size_t *received, uint_t flags)
 Read data from client request.
error_t httpWriteStream (HttpConnection *connection, const void *data, size_t length)
 Write data to the client.
error_t httpCloseStream (HttpConnection *connection)
 Close output stream.
error_t httpSendResponse (HttpConnection *connection, const char_t *uri)
 Send HTTP response.
error_t httpSendErrorResponse (HttpConnection *connection, uint_t statusCode, const char_t *message)
 Send error response to the client.
error_t httpSendRedirectResponse (HttpConnection *connection, uint_t statusCode, const char_t *uri)
 Send redirect response to the client.
bool_t httpCheckWebSocketHandshake (HttpConnection *connection)
 Check whether the client's handshake is valid.
WebSocket * httpUpgradeToWebSocket (HttpConnection *connection)
 Upgrade an existing HTTP connection to a WebSocket.

Detailed Description

HTTP server (HyperText Transfer Protocol)

License

Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Description

Using the HyperText Transfer Protocol, the HTTP server delivers web pages to browsers as well as other data files to web-based applications. Refers to the following RFCs for complete details:

  • RFC 1945: Hypertext Transfer Protocol - HTTP/1.0
  • RFC 2616: Hypertext Transfer Protocol - HTTP/1.1
  • RFC 2617: HTTP Authentication: Basic and Digest Access Authentication
  • RFC 2818: HTTP Over TLS
Author:
Oryx Embedded SARL (www.oryx-embedded.com)
Version:
1.7.6

Definition in file http_server.c.


Function Documentation

bool_t httpCheckWebSocketHandshake ( HttpConnection *  connection )

Check whether the client's handshake is valid.

Parameters:
[in]connectionStructure representing an HTTP connection
Returns:
TRUE if the WebSocket handshake is valid, else FALSE

Definition at line 1059 of file http_server.c.

error_t httpCloseStream ( HttpConnection *  connection )

Close output stream.

Parameters:
[in]connectionStructure representing an HTTP connection
Returns:
Error code

Definition at line 803 of file http_server.c.

void httpConnectionTask ( void *  param )

Task that services requests from an active connection.

Parameters:
[in]paramStructure representing an HTTP connection with a client

Definition at line 308 of file http_server.c.

void httpListenerTask ( void *  param )

HTTP server listener task.

Parameters:
[in]paramPointer to the HTTP server context

Definition at line 238 of file http_server.c.

error_t httpReadStream ( HttpConnection *  connection,
void *  data,
size_t  size,
size_t *  received,
uint_t  flags 
)

Read data from client request.

Parameters:
[in]connectionStructure representing an HTTP connection
[out]dataBuffer where to store the incoming data
[in]sizeMaximum number of bytes that can be received
[out]receivedNumber of bytes that have been received
[in]flagsSet of flags that influences the behavior of this function
Returns:
Error code

Definition at line 632 of file http_server.c.

error_t httpSendErrorResponse ( HttpConnection *  connection,
uint_t  statusCode,
const char_t *  message 
)

Send error response to the client.

Parameters:
[in]connectionStructure representing an HTTP connection
[in]statusCodeHTTP status code
[in]messageUser message
Returns:
Error code

Definition at line 948 of file http_server.c.

error_t httpSendRedirectResponse ( HttpConnection *  connection,
uint_t  statusCode,
const char_t *  uri 
)

Send redirect response to the client.

Parameters:
[in]connectionStructure representing an HTTP connection
[in]statusCodeHTTP status code (301 for permanent redirects)
[in]uriNULL-terminated string containing the redirect URI
Returns:
Error code

Definition at line 1004 of file http_server.c.

error_t httpSendResponse ( HttpConnection *  connection,
const char_t *  uri 
)

Send HTTP response.

Parameters:
[in]connectionStructure representing an HTTP connection
[in]uriNULL-terminated string containing the file to be sent in response
Returns:
Error code

Definition at line 831 of file http_server.c.

void httpServerGetDefaultSettings ( HttpServerSettings settings )

Initialize settings with default values.

Parameters:
[out]settingsStructure that contains HTTP server settings

Definition at line 61 of file http_server.c.

error_t httpServerInit ( HttpServerContext *  context,
const HttpServerSettings settings 
)

HTTP server initialization.

Parameters:
[in]contextPointer to the HTTP server context
[in]settingsHTTP server specific settings
Returns:
Error code

Definition at line 106 of file http_server.c.

error_t httpServerStart ( HttpServerContext *  context )

Start HTTP server.

Parameters:
[in]contextPointer to the HTTP server context
Returns:
Error code

Definition at line 196 of file http_server.c.

WebSocket* httpUpgradeToWebSocket ( HttpConnection *  connection )

Upgrade an existing HTTP connection to a WebSocket.

Parameters:
[in]connectionStructure representing an HTTP connection
Returns:
Handle referencing the new WebSocket

Definition at line 1108 of file http_server.c.

error_t httpWriteHeader ( HttpConnection *  connection )

Send HTTP response header.

Parameters:
[in]connectionStructure representing an HTTP connection
Returns:
Error code

Definition at line 599 of file http_server.c.

error_t httpWriteStream ( HttpConnection *  connection,
const void *  data,
size_t  length 
)

Write data to the client.

Parameters:
[in]connectionStructure representing an HTTP connection
[in]dataBuffer containing the data to be transmitted
[in]lengthNumber of bytes to be transmitted
Returns:
Error code

Definition at line 738 of file http_server.c.