http_common.c File Reference

Definitions common to HTTP client and server. More...

#include <ctype.h>
#include "core/net.h"
#include "http/http_common.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   HTTP_TRACE_LEVEL
 

Functions

error_t httpCheckCharset (const char_t *s, size_t length, uint_t charset)
 Check whether a string contains valid characters. More...
 
error_t httpParseParam (const char_t **pos, HttpParam *param)
 Parse a list of parameters. More...
 
bool_t httpCompareParamName (const HttpParam *param, const char_t *name)
 Compare parameter name with the supplied string. More...
 
bool_t httpCompareParamValue (const HttpParam *param, const char_t *value)
 Compare parameter name with the supplied string. More...
 
error_t httpCopyParamValue (const HttpParam *param, char_t *value, size_t maxLen)
 Copy the value of a parameter. More...
 
void httpEncodeHexString (const uint8_t *input, size_t inputLen, char_t *output)
 Convert byte array to hex string. More...
 

Detailed Description

Definitions common to HTTP client and server.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file http_common.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   HTTP_TRACE_LEVEL

Definition at line 32 of file http_common.c.

Function Documentation

◆ httpCheckCharset()

error_t httpCheckCharset ( const char_t s,
size_t  length,
uint_t  charset 
)

Check whether a string contains valid characters.

Parameters
[in]sPointer to the string
[in]lengthLength of the string
[in]charsetAcceptable charset
Returns
Error code

Definition at line 49 of file http_common.c.

◆ httpCompareParamName()

bool_t httpCompareParamName ( const HttpParam param,
const char_t name 
)

Compare parameter name with the supplied string.

Parameters
[in]paramPointer to the parameter
[in]nameNULL-terminated string
Returns
Comparison result

Definition at line 368 of file http_common.c.

◆ httpCompareParamValue()

bool_t httpCompareParamValue ( const HttpParam param,
const char_t value 
)

Compare parameter name with the supplied string.

Parameters
[in]paramPointer to the parameter
[in]valueNULL-terminated string
Returns
Comparison result

Definition at line 401 of file http_common.c.

◆ httpCopyParamValue()

error_t httpCopyParamValue ( const HttpParam param,
char_t value,
size_t  maxLen 
)

Copy the value of a parameter.

Parameters
[in]paramPointer to the parameter
[out]valuePointer to the buffer where to copy the parameter value
[out]maxLenMaximum number of characters the buffer can hold
Returns
Error code

Definition at line 435 of file http_common.c.

◆ httpEncodeHexString()

void httpEncodeHexString ( const uint8_t *  input,
size_t  inputLen,
char_t output 
)

Convert byte array to hex string.

Parameters
[in]inputPoint to the byte array
[in]inputLenLength of the byte array
[out]outputNULL-terminated string resulting from the conversion

Definition at line 475 of file http_common.c.

◆ httpParseParam()

error_t httpParseParam ( const char_t **  pos,
HttpParam param 
)

Parse a list of parameters.

Parameters
[in,out]posActual position if the list of parameters
[out]paramStructure that contains the parameter name and value
Returns
Error code

Definition at line 117 of file http_common.c.