FreeRDP/libfreerdp/core/gateway/http.h
Hardening dd6d829550 Allow transport_write calls to be non-blocking
This big patch allows to have non-blocking writes. To achieve
this, it slightly changes the way transport is handled. The misc transport
layers are handled with OpenSSL BIOs. In the chain we insert a
bufferedBIO that will bufferize write calls that couldn't be honored.

For an access with Tls security the BIO chain would look like this:
  FreeRdp Code ===> SSL bio ===> buffered BIO ===> socket BIO

The buffered BIO will store bytes that couldn't be send because of
blocking write calls.

This patch also rework TSG so that it would look like this in the
case of SSL security with TSG:
                                         (TSG in)
                              > SSL BIO => buffered BIO ==> socket BIO
                             /
FreeRdp => SSL BIO => TSG BIO
                             \
                              > SSL BIO => buffered BIO ==> socket BIO
                                        (TSG out)

So from the FreeRDP point of view sending something is only BIO_writing
on the frontBio (last BIO on the left).
2014-05-21 17:42:31 +02:00

99 lines
2.8 KiB
C

/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Hypertext Transfer Protocol (HTTP)
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.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.
*/
#ifndef FREERDP_CORE_HTTP_H
#define FREERDP_CORE_HTTP_H
typedef struct _http_context HttpContext;
typedef struct _http_request HttpRequest;
typedef struct _http_response HttpResponse;
#include <freerdp/types.h>
#include <freerdp/crypto/tls.h>
#include <winpr/stream.h>
struct _http_context
{
char* Method;
char* URI;
char* UserAgent;
char* Host;
char* Accept;
char* CacheControl;
char* Connection;
char* Pragma;
};
void http_context_set_method(HttpContext* http_context, char* method);
void http_context_set_uri(HttpContext* http_context, char* uri);
void http_context_set_user_agent(HttpContext* http_context, char* user_agent);
void http_context_set_host(HttpContext* http_context, char* host);
void http_context_set_accept(HttpContext* http_context, char* accept);
void http_context_set_cache_control(HttpContext* http_context, char* cache_control);
void http_context_set_connection(HttpContext* http_context, char* connection);
void http_context_set_pragma(HttpContext* http_context, char* pragma);
HttpContext* http_context_new(void);
void http_context_free(HttpContext* http_context);
struct _http_request
{
char* Method;
char* URI;
char* AuthScheme;
char* AuthParam;
char* Authorization;
int ContentLength;
char* Content;
};
void http_request_set_method(HttpRequest* http_request, char* method);
void http_request_set_uri(HttpRequest* http_request, char* uri);
void http_request_set_auth_scheme(HttpRequest* http_request, char* auth_scheme);
void http_request_set_auth_param(HttpRequest* http_request, char* auth_param);
wStream* http_request_write(HttpContext* http_context, HttpRequest* http_request);
HttpRequest* http_request_new(void);
void http_request_free(HttpRequest* http_request);
struct _http_response
{
int count;
char** lines;
int StatusCode;
char* ReasonPhrase;
wListDictionary *Authenticates;
int ContentLength;
BYTE *BodyContent;
int bodyLen;
};
void http_response_print(HttpResponse* http_response);
HttpResponse* http_response_recv(rdpTls* tls);
HttpResponse* http_response_new(void);
void http_response_free(HttpResponse* http_response);
#endif /* FREERDP_CORE_HTTP_H */