22 Commits

Author SHA1 Message Date
Fred Nicolson
c8e03f2df8 Added more tests. Tweaks.
Receiving an http request/response will now return errors like HttpHeaderTooBig, instead of the type being set to that.

Added fr::Socket::status_to_string for converting status values into English strings.
2017-09-25 16:19:47 +01:00
Fred Nicolson
abb3655739 Bug fixes and socket improvements
Added the ability to disable certificate verification for SSL sockets which is useful for testing.

Added the ability to specify maximum HTTP request header/body sizes in the CMake build config to prevent a malicious client from causing OOM errors.

Fixed a bug in HttpResponse and HttpRequest parse causing it to abort if the request is invalid in some cases.
2017-09-25 12:29:52 +01:00
Fred Nicolson
40001534ed Changed HttpResponse default connection type to keep-alive 2017-07-30 19:06:56 +01:00
Fred Nicolson
84382cad0b Made some changes recommended by Clang-Tidy. 2017-07-20 15:02:43 +01:00
Fred Nicolson
e748fde121 API changes, and lots of fixes.
fr::HttpSocket has been removed.

fr::Sendable has been added. Classes can inherit this if they want to be sendable through sockets. Both fr::Http (which is inherited by fr::HttpRequest and fr::HttpResponse), and fr::Packet inherit this, to allow them to be sent through fr::Socket::send()/fr::Socket::receive().

Fixed broken fr::SocketSelector and fr::SocketReactor, as they no longer accepted fr::Listener's due to fr::Listener no longer inheriting fr::Socket.
2017-07-18 17:34:49 +01:00
Fred Nicolson
7c9dee579f Bug fixes
Fixed HTTP Request receive expecting more bytes than there actually is, and so waiting for more bytes when there is none.
2017-07-12 16:53:34 +01:00
Unknown
93ec4fa999 Bug fixes
Fixed Content-Length header being added to Http responses even if there's a pre-existing one.

Fixed header parsing sometimes adding a carriage return to the header value.

Removed useless copy/move constructors from HttpResponse, causing issues.
2017-07-10 21:47:34 +01:00
Fred Nicolson
df509a42f5 Socket and HTTP Response bug fixes
fr::TcpSocket checked if the recv response was greater than 0, which created issues as 0 is a valid result if no data was received and no error occurred.

fr::HttpResponse::construct() now adds in a content-length header.

fr::HttpResponse::parse trims the body if it's larger than content length.

fr::Http::set_uri() now prepends a '/' if one's not provided.

Fixed fr::Http::parse_header from cutting off the end of headers.
2017-07-07 11:05:19 +01:00
Fred Nicolson
aa8509e460 Added move/copy constructors to Http & HttpResponse 2017-06-16 15:16:13 +01:00
Fred Nicolson
96567f4338 Fixed HTTP response code not being parsed
Forgot to parse it, when re-writing HTTP response parser.
2017-06-09 11:22:21 +01:00
Unknown
028677b01a Added tests. Improved error checking. Bug fixes.
Added fr::TcpListener tests.
2017-06-05 20:13:50 +01:00
Unknown
5778310798 Fixed incompatabilities between GCC and MSCV
Build errors have been fixed, but there are build warnings remaining about unsafe conversions, because Visual C++'s network conversion functions have a differing return type to mine. To be fixed in the future.
2017-05-28 18:09:29 +01:00
Fred Nicolson
b2bb3ce60b Fixed fr::HttpResponse parse bug
The spacing between the header and the body was being added into the body.
2017-05-24 14:38:01 +01:00
Fred Nicolson
53ab6e2090 Header names are automatically lower-cased now. 2017-04-11 10:39:23 +01:00
Fred Nicolson
6b1ef27764 Re-wrote HTML request/response parsing
It's now much more robust, supports requests received over multiple recvs. Supports POST variables. Supports 'content-length' header.
2017-04-10 17:24:57 +01:00
Fred Nicolson
5757eb776c Preparing to add support for larger HTTP requests 2017-04-06 14:07:03 +01:00
Fred Nicolson
27b559b4ef Added URL encoding/decoding and proper POST parsing
Also fixed last body line being ignored in requests
2016-12-31 22:05:44 +00:00
Cloaked9000
2de9540819 Added windows support. Updated build system.
CMake build system builds as a library, not an executable now.

Windows is now supported and should work fine.
2016-12-19 12:10:39 +00:00
Cloaked9000
8c94c337e9 SSL Contexts are now shared between sockets 2016-12-16 14:55:41 +00:00
Fred Nicolson
3b890972d1 Fixed 'host' HTTP header not being sent 2016-12-11 15:14:23 +00:00
Fred Nicolson
98897dec02 Cleaned up HTTP socket/request code. 2016-12-11 12:14:47 +00:00
Fred Nicolson
fdee42e300 Added ability to both send AND receive HTTP requests and responses. 2016-12-10 16:50:02 +00:00