245 Commits

Author SHA1 Message Date
Fred Nicolson
f1db713069 Made POST/GET/HEADER members case insensitive again
It broke things. Bad.
2017-08-22 13:57:08 +01:00
Fred Nicolson
fcd97d2829 Added Unprocessable Entity HTTP code to fr::Http 2017-08-04 11:45:36 +01:00
Fred Nicolson
0bd41ec6bd get_remote_address() now works on SSL sockets accepted through SSLListener
Post/get/... data is no longer case insensitive.
2017-08-02 17:32:16 +01:00
Fred Nicolson
0c7d37a8e3 Moved set_remote_address from TcpSocket to Socket
So that SSLSocket has it to. Though the SSLListener still needs to set the remote address after accepting a new connection.
2017-08-01 17:25:53 +01:00
Fred Nicolson
cfda0f969e Specified default move/copy constructors/operators to Http/Response/Request 2017-08-01 16:15:43 +01:00
Fred Nicolson
6ccd8489a7 Merge remote-tracking branch 'origin/master' 2017-07-31 11:58:27 +01:00
Fred Nicolson
dff81f495e Fixed memory leak
fr::SSLSocket did not call mbedtls_net_free. It called mbedtls_ssl_close_notify instead.
2017-07-31 11:58:22 +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
a0ca16c891 Work on fr::HttpRequest unit tests. Some tweaking.
GET variables are now actually added to the request when constructing them, instead of being ignored.
2017-07-20 10:42:18 +01:00
Fred Nicolson
f2cebd0847 Work on tests. Bug fixes and tweaks.
Started work on tests for fr::HttpRequest.

Fixed the final POST data variable containing header data it shouldn't (\r\n\r\n).

Fixed fr::Http::header_exists, and family, not converting things to lowercase first.
2017-07-19 17:30:43 +01:00
Fred Nicolson
d3b51f75a5 fr::SSLSocket bug fixes
Whilst receiving data, the SSL socket would not return if the remote socket disconnected, leading to it blocking indefinitely.

Whilst sending enough data to require multiple writes, the socket would disconnect instead of sending more. This has also been fixed.
2017-07-19 13:54:42 +01:00
Fred Nicolson
ec95d0ac36 fr::TcpSocket bug fix
Recv's return value was being checked to see if it was greater or equal to 0, if everything was okay. 0 indicates connection closed, and so the socket should have disconnected instead of returning Success.
2017-07-19 10:46:07 +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
Unknown
36f4006343 Added DELETE and PATCH support. 2017-06-19 22:42:37 +01:00
Fred Nicolson
50c62f2c4a Added PUT support 2017-06-16 17:06:34 +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
Fred Nicolson
8284644769 Merge remote-tracking branch 'origin/master' 2017-06-09 09:42:56 +01:00
Fred Nicolson
1f957649b0 Set SO_EXCLUSIVEADDRUSE option on Windows
This should prevent potential port hijacking.
2017-06-09 09:42:53 +01:00
Unknown
028677b01a Added tests. Improved error checking. Bug fixes.
Added fr::TcpListener tests.
2017-06-05 20:13:50 +01:00
Fred Nicolson
08ed4a2354 Update README.md 2017-06-05 13:36:09 +01:00
Unknown
c7a25fa01e Added license 2017-06-04 20:09:24 +01:00
Unknown
eec983c8b7 Added fr::Socket::set_max_packet_size
Can be used to limit the size of packets being received, to prevent malicious attacks.
2017-06-03 14:39:49 +01:00
Fred Nicolson
71874837a0 Added 'WebSocket'.
This is just an abstract class which is inherited by fr::HttpSocket<T>, to allow different web socket types to be stored in a generic container.
2017-06-02 16:38:06 +01:00
Unknown
eb136c71f9 Fixed builds with shared libraries enabled failing 2017-06-01 10:46:38 +01:00
Unknown
0778f30d10 Prevented MSVC's inbuild network conversion functions being used
These functions did not play well with the rest of the code, causing float conversion to produce an incorrect value.
2017-05-31 17:02:40 +01:00
Fred Nicolson
bbcf185202 Improved build system
Examples and tests now build on Windows
2017-05-31 16:23:35 +01:00
Fred Nicolson
0a00f0ca61 Merge remote-tracking branch 'origin/master' 2017-05-31 09:35:00 +01:00
Unknown
128ebbd272 Updated readme to include Travis CI build status badge 2017-05-30 20:09:38 +01:00
Unknown
adc891fc84 Tweaked build system 2017-05-30 19:58:40 +01:00
Fred Nicolson
df2425a94d Added fr::Packet tests and Travis CI file. 2017-05-30 17:07:41 +01:00
Fred Nicolson
dd4d45d183 Improved tests
Fixed tests not being linked properly with frnetlib.

Added tests for the URL parser.
2017-05-30 15:32:45 +01:00
Unknown
a6a652e72b Fixed CMake build issues
Tests and examples however, still do not work on Windows and so are disabled by default for now.
2017-05-30 10:51:42 +01:00
Unknown
6c0762bbf2 Integrated googletest into the project
The plan is to add unit tests, to completely test library functionality, alongside continuous integration on GitHub.
2017-05-29 22:55:17 +01:00
Unknown
1eec21c679 Fixed Cmake error 2017-05-29 19:04:44 +01:00
Unknown
1b64bbbb67 Cleaned up mess 2017-05-29 18:59:33 +01:00
Unknown
bf8a6345d7 Merge remote-tracking branch 'origin/master' 2017-05-29 18:57:47 +01:00
Unknown
c4fea83a2c Added support for examples to the build system. Cleaned up examples.
Examples can now be automatically built with the project, if enabled. And I've cleaned up MiaoDX's examples to be more compliant with frnetlib's coding style.
2017-05-29 18:57:39 +01:00
Fred Nicolson
0385ea57f9 Merge pull request #8 from MiaoDX-fork-and-pruning/more_examples
More examples, and fix the link problem in linux introduced by my careless.
2017-05-29 18:55:18 +01:00
miaodx
7dccf41b76 specify the ip and port. 2017-05-29 23:49:03 +08:00
miaodx
8a380c6620 add FRNETLIB_LIB for apple and linux. 2017-05-29 23:48:31 +08:00
miaodx
bb9eaa3981 tcpsocket client and server example. 2017-05-29 23:19:27 +08:00
Fred Nicolson
2d1cf169db Merge pull request #7 from MiaoDX-fork-and-pruning/add_some_examples
Make build with `SSL` support optional, and add some examples.
2017-05-29 09:06:14 +01:00
miaodx
1de53ef6e8 add some examples. 2017-05-29 09:42:14 +08:00
miaodx
f1d1d0849e reorganize the include files according to the SSL_ENABLED flag.
So that we can build without ssl support.
2017-05-29 09:36:20 +08: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