134 Commits

Author SHA1 Message Date
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
Fred Nicolson
ae61464aee Removed is_connected flag in fr::Socket
The socket descriptor is now checked, to see if it's greater than 0, instead. This means that the flag doesn't have to be manually updated.
2017-05-25 16:21:39 +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
e0f68fb037 Added const specifiers to fr::URL members 2017-05-24 13:45:33 +01:00
Fred Nicolson
64cce75bda Added port detection to URL parser, if not specified.
Before, if you parsed a URL using fr::URL, and a port wasn't explicitly mentioned in the URL, then fr::URL::get_port() would return an empty string. 

Now, it will try to detect the port type if none is specified. For example, URLs beginning with http, will be given a port of 80. This is to simplify usage of the URL class.
2017-05-24 11:05:14 +01:00
Fred Nicolson
431f646bae Moved URL class into fr namespace
It should not have been in the global namespace, as it's a part of the library.
2017-05-24 09:54:19 +01:00
Fred Nicolson
c110fb6c81 Updated ReadMe to be compatable with code changes and fixed typos
The SSLConect interface has changed, and so the readme text explaining it has been updated.

There were various typos which have been corrected.
2017-05-23 21:57:32 +01:00
Fred Nicolson
7d0edb160e Bug fixes. Added ability to set ai_family on SSL listeners.
fr::Listener's destructor wasn't virtual, so children's destructors weren't being called.

fr::TcpListener did not have a destructor, and so did not close its socket on destruction. 

fr::SSLListener now uses fr::TcpListener's 'listen' function instead of its own, as a temporary hack, as mbedtls does not support setting the address families.

Added get/set functions to the listeners for their socket descriptors.
2017-05-23 21:17:39 +01:00
Fred Nicolson
68c214ef7e Merge pull request #5 from Cloaked9000/Mbedtls_Modified
Mbedtls modified
2017-05-23 20:48:45 +01:00
Fred Nicolson
ca95bb326e Fixed CMake error
Accidentally set CXX flags twice
2017-05-23 17:04:06 +01:00
Fred Nicolson
b34ada36d1 Compilation error fixed 2017-05-23 16:57:21 +01:00
Fred Nicolson
40f8ccb067 Added URL parsing class
Allows the parsing of full URLs into easy chunks. Added as a helper class for users of the library dealing with URLs, and to potentially replace some of the HTTP parsing code in the future.
2017-05-23 16:52:55 +01:00