FreeRDP
http.c File Reference
#include <freerdp/config.h>
#include <errno.h>
#include <winpr/crt.h>
#include <winpr/print.h>
#include <winpr/stream.h>
#include <winpr/string.h>
#include <freerdp/log.h>
#include <freerdp/crypto/crypto.h>
#include <winpr/crypto.h>
#include "http.h"

Macros

#define TAG   FREERDP_TAG("core.gateway.http")
 
#define RESPONSE_SIZE_LIMIT   64 * 1024 * 1024
 
#define WEBSOCKET_MAGIC_GUID   "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
 

Functions

static char * string_strnstr (char *str1, const char *str2, size_t slen)
 
static BOOL strings_equals_nocase (const void *obj1, const void *obj2)
 
static void * copy_string (const void *ptr)
 
HttpContext * http_context_new (void)
 
BOOL http_context_set_method (HttpContext *context, const char *Method)
 
BOOL http_request_set_content_type (HttpRequest *request, const char *ContentType)
 
const char * http_context_get_uri (HttpContext *context)
 
BOOL http_context_set_uri (HttpContext *context, const char *URI)
 
BOOL http_context_set_user_agent (HttpContext *context, const char *UserAgent)
 
BOOL http_context_set_x_ms_user_agent (HttpContext *context, const char *X_MS_UserAgent)
 
BOOL http_context_set_host (HttpContext *context, const char *Host)
 
BOOL http_context_set_accept (HttpContext *context, const char *Accept)
 
BOOL http_context_set_cache_control (HttpContext *context, const char *CacheControl)
 
BOOL http_context_set_connection (HttpContext *context, const char *Connection)
 
BOOL http_context_set_pragma (HttpContext *context, const char *Pragma)
 
BOOL http_context_set_rdg_connection_id (HttpContext *context, const char *RdgConnectionId)
 
BOOL http_context_enable_websocket_upgrade (HttpContext *context, BOOL enable)
 
BOOL http_context_is_websocket_upgrade_enabled (HttpContext *context)
 
BOOL http_context_set_rdg_auth_scheme (HttpContext *context, const char *RdgAuthScheme)
 
BOOL http_context_set_cookie (HttpContext *context, const char *CookieName, const char *CookieValue)
 
void http_context_free (HttpContext *context)
 
BOOL http_request_set_method (HttpRequest *request, const char *Method)
 
BOOL http_request_set_uri (HttpRequest *request, const char *URI)
 
BOOL http_request_set_auth_scheme (HttpRequest *request, const char *AuthScheme)
 
BOOL http_request_set_auth_param (HttpRequest *request, const char *AuthParam)
 
BOOL http_request_set_transfer_encoding (HttpRequest *request, TRANSFER_ENCODING TransferEncoding)
 
static BOOL http_encode_print (wStream *s, const char *fmt,...)
 
static BOOL http_encode_body_line (wStream *s, const char *param, const char *value)
 
static BOOL http_encode_content_length_line (wStream *s, size_t ContentLength)
 
static BOOL http_encode_header_line (wStream *s, const char *Method, const char *URI)
 
static BOOL http_encode_authorization_line (wStream *s, const char *AuthScheme, const char *AuthParam)
 
static BOOL http_encode_cookie_line (wStream *s, wListDictionary *cookies)
 
wStreamhttp_request_write (HttpContext *context, HttpRequest *request)
 
HttpRequest * http_request_new (void)
 
void http_request_free (HttpRequest *request)
 
static BOOL http_response_parse_header_status_line (HttpResponse *response, const char *status_line)
 
static BOOL http_response_parse_header_field (HttpResponse *response, const char *name, const char *value)
 
static BOOL http_response_parse_header (HttpResponse *response)
 
BOOL http_response_print (HttpResponse *response)
 
static BOOL http_use_content_length (const char *cur)
 
static int print_bio_error (const char *str, size_t len, void *bp)
 
int http_chuncked_read (BIO *bio, BYTE *pBuffer, size_t size, http_encoding_chunked_context *encodingContext)
 
HttpResponse * http_response_recv (rdpTls *tls, BOOL readContentLength)
 
const BYTEhttp_response_get_body (HttpResponse *response)
 
static BOOL set_compare (wListDictionary *dict)
 
HttpResponse * http_response_new (void)
 
void http_response_free (HttpResponse *response)
 
const char * http_request_get_uri (HttpRequest *request)
 
SSIZE_T http_request_get_content_length (HttpRequest *request)
 
BOOL http_request_set_content_length (HttpRequest *request, size_t length)
 
long http_response_get_status_code (HttpResponse *response)
 
SSIZE_T http_response_get_body_length (HttpResponse *response)
 
const char * http_response_get_auth_token (HttpResponse *response, const char *method)
 
const char * http_response_get_setcookie (HttpResponse *response, const char *cookie)
 
TRANSFER_ENCODING http_response_get_transfer_encoding (HttpResponse *response)
 
BOOL http_response_is_websocket (HttpContext *http, HttpResponse *response)
 
const char * http_status_string (long status)
 
char * http_status_string_format (long status, char *buffer, size_t size)
 

Macro Definition Documentation

◆ RESPONSE_SIZE_LIMIT

#define RESPONSE_SIZE_LIMIT   64 * 1024 * 1024

◆ TAG

#define TAG   FREERDP_TAG("core.gateway.http")

FreeRDP: A Remote Desktop Protocol Implementation Hypertext Transfer Protocol (HTTP)

Copyright 2012 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

◆ WEBSOCKET_MAGIC_GUID

#define WEBSOCKET_MAGIC_GUID   "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"

Function Documentation

◆ copy_string()

static void* copy_string ( const void *  ptr)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_chuncked_read()

int http_chuncked_read ( BIO *  bio,
BYTE pBuffer,
size_t  size,
http_encoding_chunked_context encodingContext 
)
Here is the caller graph for this function:

◆ http_context_enable_websocket_upgrade()

BOOL http_context_enable_websocket_upgrade ( HttpContext *  context,
BOOL  enable 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_free()

void http_context_free ( HttpContext *  context)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_get_uri()

const char* http_context_get_uri ( HttpContext *  context)
Here is the caller graph for this function:

◆ http_context_is_websocket_upgrade_enabled()

BOOL http_context_is_websocket_upgrade_enabled ( HttpContext *  context)
Here is the caller graph for this function:

◆ http_context_new()

HttpContext* http_context_new ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_accept()

BOOL http_context_set_accept ( HttpContext *  context,
const char *  Accept 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_cache_control()

BOOL http_context_set_cache_control ( HttpContext *  context,
const char *  CacheControl 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_connection()

BOOL http_context_set_connection ( HttpContext *  context,
const char *  Connection 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_cookie()

BOOL http_context_set_cookie ( HttpContext *  context,
const char *  CookieName,
const char *  CookieValue 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_host()

BOOL http_context_set_host ( HttpContext *  context,
const char *  Host 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_method()

BOOL http_context_set_method ( HttpContext *  context,
const char *  Method 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_pragma()

BOOL http_context_set_pragma ( HttpContext *  context,
const char *  Pragma 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_rdg_auth_scheme()

BOOL http_context_set_rdg_auth_scheme ( HttpContext *  context,
const char *  RdgAuthScheme 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_rdg_connection_id()

BOOL http_context_set_rdg_connection_id ( HttpContext *  context,
const char *  RdgConnectionId 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_uri()

BOOL http_context_set_uri ( HttpContext *  context,
const char *  URI 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_user_agent()

BOOL http_context_set_user_agent ( HttpContext *  context,
const char *  UserAgent 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_context_set_x_ms_user_agent()

BOOL http_context_set_x_ms_user_agent ( HttpContext *  context,
const char *  X_MS_UserAgent 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_encode_authorization_line()

static BOOL http_encode_authorization_line ( wStream s,
const char *  AuthScheme,
const char *  AuthParam 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_encode_body_line()

static BOOL http_encode_body_line ( wStream s,
const char *  param,
const char *  value 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_encode_content_length_line()

static BOOL http_encode_content_length_line ( wStream s,
size_t  ContentLength 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_encode_cookie_line()

static BOOL http_encode_cookie_line ( wStream s,
wListDictionary *  cookies 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_encode_header_line()

static BOOL http_encode_header_line ( wStream s,
const char *  Method,
const char *  URI 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_encode_print()

static BOOL http_encode_print ( wStream s,
const char *  fmt,
  ... 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_request_free()

void http_request_free ( HttpRequest *  request)
Here is the caller graph for this function:

◆ http_request_get_content_length()

SSIZE_T http_request_get_content_length ( HttpRequest *  request)

◆ http_request_get_uri()

const char* http_request_get_uri ( HttpRequest *  request)

◆ http_request_new()

HttpRequest* http_request_new ( void  )
Here is the caller graph for this function:

◆ http_request_set_auth_param()

BOOL http_request_set_auth_param ( HttpRequest *  request,
const char *  AuthParam 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_request_set_auth_scheme()

BOOL http_request_set_auth_scheme ( HttpRequest *  request,
const char *  AuthScheme 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_request_set_content_length()

BOOL http_request_set_content_length ( HttpRequest *  request,
size_t  length 
)
Here is the caller graph for this function:

◆ http_request_set_content_type()

BOOL http_request_set_content_type ( HttpRequest *  request,
const char *  ContentType 
)
Here is the call graph for this function:

◆ http_request_set_method()

BOOL http_request_set_method ( HttpRequest *  request,
const char *  Method 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_request_set_transfer_encoding()

BOOL http_request_set_transfer_encoding ( HttpRequest *  request,
TRANSFER_ENCODING  TransferEncoding 
)
Here is the caller graph for this function:

◆ http_request_set_uri()

BOOL http_request_set_uri ( HttpRequest *  request,
const char *  URI 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_request_write()

wStream* http_request_write ( HttpContext *  context,
HttpRequest *  request 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_response_free()

void http_response_free ( HttpResponse *  response)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_response_get_auth_token()

const char* http_response_get_auth_token ( HttpResponse *  response,
const char *  method 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_response_get_body()

const BYTE* http_response_get_body ( HttpResponse *  response)
Here is the caller graph for this function:

◆ http_response_get_body_length()

SSIZE_T http_response_get_body_length ( HttpResponse *  response)
Here is the caller graph for this function:

◆ http_response_get_setcookie()

const char* http_response_get_setcookie ( HttpResponse *  response,
const char *  cookie 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_response_get_status_code()

long http_response_get_status_code ( HttpResponse *  response)
Here is the caller graph for this function:

◆ http_response_get_transfer_encoding()

TRANSFER_ENCODING http_response_get_transfer_encoding ( HttpResponse *  response)
Here is the caller graph for this function:

◆ http_response_is_websocket()

BOOL http_response_is_websocket ( HttpContext *  http,
HttpResponse *  response 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_response_new()

HttpResponse* http_response_new ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_response_parse_header()

static BOOL http_response_parse_header ( HttpResponse *  response)
static

name end_of_header | | v v <header name> : <header value> ^ ^ | | colon_pos value

Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_response_parse_header_field()

static BOOL http_response_parse_header_field ( HttpResponse *  response,
const char *  name,
const char *  value 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_response_parse_header_status_line()

static BOOL http_response_parse_header_status_line ( HttpResponse *  response,
const char *  status_line 
)
static
Here is the caller graph for this function:

◆ http_response_print()

BOOL http_response_print ( HttpResponse *  response)
Here is the caller graph for this function:

◆ http_response_recv()

HttpResponse* http_response_recv ( rdpTls *  tls,
BOOL  readContentLength 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_status_string()

const char* http_status_string ( long  status)
Here is the caller graph for this function:

◆ http_status_string_format()

char* http_status_string_format ( long  status,
char *  buffer,
size_t  size 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ http_use_content_length()

static BOOL http_use_content_length ( const char *  cur)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_bio_error()

static int print_bio_error ( const char *  str,
size_t  len,
void *  bp 
)
static
Here is the caller graph for this function:

◆ set_compare()

static BOOL set_compare ( wListDictionary *  dict)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ string_strnstr()

static char* string_strnstr ( char *  str1,
const char *  str2,
size_t  slen 
)
static
Here is the caller graph for this function:

◆ strings_equals_nocase()

static BOOL strings_equals_nocase ( const void *  obj1,
const void *  obj2 
)
static
Here is the call graph for this function:
Here is the caller graph for this function: