Giter VIP home page Giter VIP logo

eidheim / simple-web-server Goto Github PK

View Code? Open in Web Editor NEW
2.6K 173.0 756.0 6.57 MB

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.

License: MIT License

C++ 97.30% HTML 0.20% CMake 2.49%
cpp web rest http https server client asio library

simple-web-server's People

Contributors

aaalgo avatar arash-codedev avatar bjorkegeek avatar bryant1410 avatar classix-do avatar craigminihan avatar draconpern avatar dsiroky avatar eidheim avatar fivethreeo avatar iamthebot avatar k1988 avatar knowledge4igor avatar maufeat avatar moodboom avatar ntadas avatar pboettch avatar sebt3 avatar sethhamilton avatar skywalker13 avatar techpriest avatar tkarls avatar tylawin avatar venediktov avatar vitor-alves avatar waga-git avatar zalox avatar zethon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-web-server's Issues

can't get index page to display

I am running the https_examples and the https server comes up, starts with the self signing certificate and key file, and the https clients examples from within the c++ file connect and the server couts the data correctly on the output. However, nothing happens when pointing the browser to https://localhost:8080, either with firefox nor ie. First time, I had the certificate warning (because of the self signing situation), I then added an exception, and now no longer a warning but simply a give up message.
On the server side, I get the boost "size_t win_iocp_io_service::do_one(bool block, boost::system::error_code& ec)" function is called and goes into op->complete, however nothing seems to be sent to the browser in response to its GETS request.

Request that compilation with -WEverything should compile cleanly

Really great work however in our code base we always compile with -WEverything and -Werror under clang which produce a lot of warnings hence errors. I am willing to fix all the warning and issue a pull request as long as you are fine with it?

You have the habit of using the same name for parameter and member variable which produce a warning such as "declaration shadows a local variable". To fix that I need to introduce a naming convention such as member_ or something similar and I would like to know, in that case, what you prefer?

Recommended lifetime of HttpClient? (documentation request)

First of all, thanks for making this. I wasted much time with a different library first, and life got much better when I switched to yours.

I have an app with a server that listens to several endpoints. One of them is /clocktick. In order to test this app, I made a tester which assigns to each endpoint a key on the keyboard. So, when I press enter the tester app sends an empty POST request at '/clocktick'.

I have noticed that if I hit enter quickly (say, once per second) the requests make it through. But if I stop and wait for six seconds, and then hit it, the request will get dropped and I will get an exception when client.request is called (read_until: An established connection was aborted by the software on your host machine). I noticed a timeout in your README.md of 5 seconds--it seems like HttpClient holds a connection open for some duration, and if I catch it while that connection is closing I have the problem. If I wait longer, there is a delay for the first request--perhaps it is reopening a connection?

I create an instance of HttpClient when my program starts up and pass pointers to interested classes so they can each use it (i.e. dependency injection). I'm thinking maybe it would be better if the client was created right before it was needed, and then disposed of until next use--that way there would be no risk of catching it in the 5-seconds-later window where it doesn't work. Would that make sense?

I plan to investigate using Simple-WebSocket-Server to propagate clockticks instead--but I do still plan to use Simple-Web-Server for other resources and it would give me a nice happy feeling if I understood a bit more about what was happening regarding those timeouts. This issue is to request that you expand the readme a bit so that users of your library are better prepared to use it in a way that makes sense.

Also, if this is basic knowledge about HTTP that a typical user should already know, then I apologize and thank you for your time.

headers map

Pretty sure you're going to have hard to find bugs with your method of parsing headers. By using an unordered_map, you're not going to be able to store multiple headers with the same key identifier, such as set-cookie. Correct way would to use std::multimap with case insensitive comparison on your keys.

terminate of 'std::invalid_argument', what(): read: End of file

hi,
as in the title, i came across a error in:
json_string = "{"task_name": "ngram", "params": ["%E8%80%81%E5%90%8C%E5%AD%A6", "2"]}"
response << "HTTP/1.1 200 OK\r\nContent-Length: " << line.length() << "\r\n\r\n" << json_string;

can you help me ;), thank you very mych.

[feature] http2 support

I think a really nice addition to this library would be adding http2 support. This is particularly beneficial for high performance API applications since http2 supports multiplexing and has a lower overhead.

The first (easy) option:
libnghttp2 has a mature implementation so the easier way forward would be to provide a wrapper so we could do something like:

SimpleWeb::Server<SimpleWeb::HTTP2> HttpServer;

Of course, that would make the library no longer header-only (which isn't a big deal IMO) and add a dependency.

The harder option:
A custom http2 implementation. This would provide nicer integration and you could provide transparent backwards compatibility on a single endpoint this way.

Thoughts?

Correctly handle bind: Address already in use

Hello!

Thanks for your clean and nice code!

But I've got this error about already running another instance:

Start server
Wait for server shutdown
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'
  what():  bind: Address already in use
Aborted

From my point of view it's pretty useful thing to handle this case explicitly.

SimpleWeb::Server waits for more data if Content-Length is smaller than already transmitted data

Steps to reproduce

  • Create a SimpleWebserver app which listens to POST requests on port 80 and sends arbitrary replies.
  • Create file with following content:
POST /test HTTP/1.1
Content-Length: 6
Content-Type: application/x-www-form-urlencoded

name=a&junk=data
  • Start App and call type <filename> | nc localhost 80
  • Webserver doesn't answer and resource handler doesn't get called.

Probable cause

In server_http.hpp Line 253 boost::asio::transfer_exactly(content_length-num_additional_bytes),

If content_length is smaller than num_additional_bytes the calculation overflows and boost::asio tries to read a huge amount of bytes instead of returning instantly.

Fail to create shared pointer from HttpServer

typedef SimpleWeb::Server<SimpleWeb::HTTP> HttpServer; 
...
HttpServer server(8080,1);  
std::shared_ptr<HttpServer> pServer = std::make_shared<HttpServer>(server);
xxxx.RegisterApis(pServer);
yyyy.RegisterApis(pServer);

When I try this, it results in multiple errors ...

  • error : boost::asio::io_service::io_service(const boost::asio::io_service&)' is implicitly deleted because the default definition would be ill-formed:
  • error: 'boost::asio::detail::noncopyable::noncopyable(const boost::asio::detail::noncopyable&)' is private
    noncopyable(const noncopyable&);
  • error: use of deleted function 'boost::asio::basic_socket_acceptorboost::asio::ip::tcp::basic_socket_acceptor(const boost::asio::basic_socket_acceptorboost::asio::ip::tcp&)'
    class ServerBase

Are there solutions to solve this problems ?
I would like to pass the server pointer to a function that registers resources in the std_unordered_map recource.

Thanks in advance

Please make context, coroutine an optional dependency

boost context and by extension coroutine on MSVC requires MASM to build. MASM only comes with Visual Studio 2005 which is far behind 2014 and difficult to obtain. If possible please detect context and coroutine, other wise fall back on just threads. If that is not possible a CMAKE option would be an acceptable alternative.

default or empty header may cause negative response

On line 38 in the file client_http.hpp in the method "request" the header is defaulted to a map.

On line 52 this header is added to the payload. If the map has empty strings (or is left to the default) the
payload will have lines with just a ':' and "\r\n" in it. This causes issues on some servers.

Fix: replace this:
for(auto& h: header) {
write_stream << h.first << ": " << h.second << "\r\n";
}

With this:
for(auto& h: header) {
if ( ( ! h.first.empty() ) && (! h.second.empty() ) )
write_stream << h.first << ": " << h.second << "\r\n";
}

A error aout the POST method.

I have the follow code snippet:

        .... ....
    XMLHttpReq=false;
    createXMLHttpRequest();
    XMLHttpReq.onreadystatechange = handleResponse_upload; // as following definition
    XMLHttpReq.open("POST","http://local:8080/json", true);
    XMLHttpReq.send('{"firstName": "John", "lastName": "Smith", "age":25 }');
        .... ....
//handle the request
function handleResponse_upload(){
    if(XMLHttpReq.readyState == 4){ //  line error  ---- !!!!
    if(XMLHttpReq.status == 200)
    {

        var res = XMLHttpReq.responseXML;
                .... ....

In your Simple-Web-Server http_examples.cpp, i insert some code as following:

    server.resource["^/json$"]["POST"]=[](HttpServer::Response& response,
        shared_ptr<HttpServer::Request> request) {
        try {
            //cout<<request->content.rdbuf()<<endl;
            ptree pt;
            read_json(request->content, pt);

            string name = pt.get<string>("firstName")+" "+
                pt.get<string>("lastName");

            //line 1 --- - - !!!
            cout<<"before: "<<name<<" "<<name.size()<<endl;

            response << "HTTP/1.1 200 OK\r\nContent-Length: "<< name.length() << "\r\n\r\n" << name;
             //line 2 --- - - !!!
            cout<<"end: "<<name<<endl;
        }
        catch(exception& e) {
            response << "HTTP/1.1 400 Bad Request\r\nContent-Length: "
                << strlen(e.what()) << "\r\n\r\n" << e.what();
        }
    };

In my test, line 1 and line 2 can have a output right.
However, XMLHttpReq.readyState always 1.
I can't receive the text ...

Can you give me some help?

Thank you.

Version 2.0

This library was created mainly as a really simple way to create REST resources in C++, at a time when there were no good alternatives available. However, now, I'd like to make this library fully asynchronous, and thus more flexible regarding thread strategies. It would then be more like https://github.com/eidheim/Simple-WebSocket-Server, which I am more happy with. Of course, the default_resource example would be slightly more complex, and would have to rely on recursive calls (much like the express library for NodeJS). The resource signature would also become:

[](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request)

instead of the current:

[](HttpServer::Response& response, shared_ptr<HttpServer::Request> request)

One other advantage is a slight speed increase due to removing boost::asio::spawn and boost::asio::yield_context. Feel free to post opinions on this.

Decode http path and header values

The path passed to the server is percent encoded, and it includes the query and fragment field. Lets call it the http_path. http_path = path [+ query] [+ fragment]. The query starts with ? and the fragment starts with # (see RFC3986).

The current server implementation ignores this. The pattern matching for routing the request is currently performed on the encoded http_path. Shouldn't the routing be performed on the decoded path ?

The query and its parameters could be stored decoded in an unordered_multimap and the fragment in a string.

The client has a similar problem. It should encode the http_path.

can't make when trying to connect mysql

when I am trying to connect to db through "mysql.h", I am getting error like

http_examples.cpp:(.text+0x2967): undefined reference to `mysql_init'
http_examples.cpp:(.text+0x2990): undefined reference to `mysql_real_connect'
http_examples.cpp:(.text+0x2bc6): undefined reference to `mysql_free_result'
http_examples.cpp:(.text+0x2bd2): undefined reference to `mysql_close'
http_examples.cpp:(.text+0x2d03): undefined reference to `mysql_error'.

How can i fix it?

Request to simplify the resource definition

I'm finding it very wordy and tedious to keep typing the resource signature for all my callback handlers. With my copy of your library I've replaced the following lines and I'm hoping this could be pushed into your tree in one form or another.

    typedef std::function<void(typename ServerBase<socket_type>::Response&, std::shared_ptr<typename ServerBase<socket_type>::Request>)> Resource;

    std::unordered_map<std::string, std::unordered_map<std::string, Resource>>  resource;
    std::unordered_map<std::string, Resource> default_resource;

private:
    std::vector<std::pair<std::string, std::vector<std::pair<boost::regex, Resource>>>> opt_resource;

Unused Parameter Warning

line 27 in server_http.hpp

Response(boost::asio::io_service& io_service, socket_type &socket, boost::asio::yield_context& yield):
                    std::ostream(&streambuf), yield(yield), socket(socket) {}

generates an unused parameter warning (gcc). Easily fixed by removing parameter name

Response(boost::asio::io_service&, socket_type &socket, boost::asio::yield_context& yield):
                    std::ostream(&streambuf), yield(yield), socket(socket) {}

When starting Two server instances on diferent ports (even different interfaces) on same program just the second one works.

When starting two server instances on different ports (even different interfaces) on same program just the second one works. It looks like the instantiation of two servers on a single program, running in deferent treads and not sharing anything, is not supported as, some how the second one blocks the first one.
If you need me to provide more information i will be a pleasure!
Very nice library by the way!

Maximum threads for Http Server

Hi,

How many maximum threads can be created for Http Server. As it said 4 over in the code.

HttpServer server(8002, 4);

Also i want to know what is the maximum length of response data.

Thanks in advance.

How to parse GET request

Hi,

I'm working on http server, and i want to know how the GET request is been parsed in boost.

Let say, below is the http GET request
http://localhost:8080/match/gt5jjdsc7juty/details?stuId=207&stuGroup=501&maxResults=20

I want to get,

string a = gt5jjdsc7juty, string b = details, int c = 207, int d = 501, int e = 20
Note:
But i can able to fetch integer values as in code. Also i want to get contents which are after &, ?, / and =

Sample Code block
server.resource["^/match/([0-9]+)$"]["GET"]=[](HttpServer::Response& response, shared_ptr<HttpServer::Request> request) { string number=request->path_match[1];
Thanks in advance.

Localhost, Mozilla Firefox

Hello,

I am using this web server. Localhost is very slow (5 seconds to generate the HTML page) on the browser MozillaFirefox (even for a simple 'hello world'). I worked on Linux.

I have tried with Opera and Chrome, it is very fast.
I tried connecting to localhost using Apache on MozillaFirefox , no problem.

Do you know what can cause this problem ?

Thanks for your help !

Can't use an output-only stream as request content

Hi eidheim,

In client_http.h, ClientBase::request function is declared as:

std::shared_ptr<Response> request(const std::string& request_type, const std::string& path, std::ostream& content, 
const std::map<std::string, std::string>& header=std::map<std::string, std::string>())

But if we actually use an output-only stream like std::ostringstream for content, the request would fail because content.rdbuf() would return an empty buffer.
You can examine the behavior by changing the following line in http_examples.cpp:

stringstream ss(json);

to

ostringstream ss(json);

Running the modified program will make the main thread hang at the subsequent client request call.
My solution: change content's declared type to std::iostream&, enforcing it to be a input-output stream.
Also, please consider adding some overloads of the request function to support other content types, such as boost::string_ref.

Thanks.

http_example, ios::binary

I think in you're http_example the file should be opened with ios::binary flag. So it is possible to send e.g. images.

TCP packet handling on Linux behavior differs from OSX

When I stream mjpeg data on OSX it is working as expected with the tcp nodelay option being set. Capturing the raw data via wireshark I can clearly see the tcp packets are more or less the size of the specified MTU (~1500 bytes) and the web client plays back the images properly with the expected framerate.

Now running my application on Linux the mjpeg stream data seems to combining multiple http messages together, I am seeing tcp packets with a size more or less comparable to 65535 bytes. I've tried enabling the TCP_CORK option via acquiring the native handle but i'm not seeing a difference in packet sizes on linux. I would say it's almost like boost or the http server is holding back until the tcp buffer is full.

Any thoughts?

how to enable keep_alive in the HTTP(S) client

I would like to keep the connection open to make a Prepare request (POST) then an Excexute request (POST) to my database server (with the same connection). With the ability to close the connection by calling something like close() after I sent both requests with the connection.

in python (request module) you open the connection then make the requests then call connection.close() to close the connection to the server

Can't access the same resource in concurrent way

Hello, it's seems the server doesn't support the client access the same resource in concurrent before the previous operation is not returned ?

For example here has the resource: http://192.168.0.28/match/123, I use the Chrome to access it, the server takes a few seconds say 10 seconds to find the process this request likes query database. During that if I use firefox to access http://192.168.0.28/match/123, seems the resource handle function didn't called until the first operation returned.

CMake Windows Support

Does this project support CMake on windows? I am having issues generating a project for Visual Studio 2015.

Using Boost-free ASIO

Hi @eidheim,
thanks for your wonderfully clean project.
One question: since you're using only ASIO from Boost, is it planned to avoid Boost dependencies altogether by using the Boost-free version?

Thanks and ciao,

R

Multiple Get requests on the same connection can fail because too many bytes are read

Hi,

I've been studying and testing this Simple Web Server and I found that if you send two requests, that have no body, over the same socket then bytes could be read (in the async_read_until(... "\r\n") that belong to the second request.

You even mention in the comment that Boost could do this. The solution you mention only works if there is a body after the first request. If there isn't the bytes will eventually be lost when the first request instance containing the streambuf is destructed. For the second request on the same connection a new streambuf is used so previously read bytes beyond the first request are lost forever.

This is what I sent over the connection in one go: "GET /match/123 HTTP/1.1\r\n\r\nGET /match/456 HTTP/1.1\r\n\r\n" and what I saw happening was that the first 5 bytes of the second GET were also read from the socket and as a result they were missing when processing the second request.

Cheers,

Tim

Boost required version 1.54?

Why is the required version in the CMakeLists 1.54? Changing the version requirement so it's >= 1.53 lets it build correctly (and it seems to work correctly) on RHEL7.2/CentOS 7.

How to set the timeout value for the client request ?

Hello, I have two questions need help:

  1. When I use HttpClient to POST/GET to server, how to set the timeout if the server doesn't respond in a given time then the HttpClient will returned once the request is timeout ?
  2. It's possible to make the HttpClient works as asynchronous mode ?

Thanks & regards,

Streaming video and multiple thread issue.

At the moment I am able to stream a video source to multiple clients (based on the number of client threads issued upon the web server's construction) and keep the session active with the content_timeout set to Zero. With content_timeout set to any other value the video stream is terminated by the web server since I never exit the anonymous function in order to keep the stream active.

The sudo code below gives you an idea on how its currently implemented.

void StreamVideo(Response& response, Request request)
{
response << "multipart stream";
response.flush();

while (client_sessions_active)
{
    response << "content length";
    response.flush();
    response.write(video_stream_buffer, video_stream_buffer_size);
    response.flush;
}

}

Now I have two questions:

1: Does logic seem correct to you, rest apis usually return from the anonymous functions. Thus your timeout handling makes sense, but to keep streams active... I must specify a zero value to content_timeout, but it then is applied to all other requests that could benefit from having a content_timeout specified. Perhaps a default content_timeout could be via the constructor and overridden upon anonymous function assignment?!?

2: It seems if I go beyond the 4 client threads, I loose all my active streams and I'm unable to reestablish any new connections to the web server. Do you have any thoughts on why this happens. It should be reproducible by never existing an anonymous function with a timeout of Zero.

Reinstate async_flush please.

I've come across an issue where I'm streaming data to two clients and I'm having async_writes interleaving between both clients and when this occurs the async_write hangs. I believe you had previously solved this problem with your async_flush method (removed around Sept. 2015).

This link provides a better idea of what I'm experiencing:

http://stackoverflow.com/questions/7754695/boost-asio-async-write-how-to-not-interleaving-async-write-calls

EDIT

I ran a quick test with the version that still supported async_flush and with a quick hack of making those methods public, it worked perfectly as expected.

Use JSON post with AJAX

Hi,
I really like this project. I'd like to contribute in some way!

Is it possible to use AJAX (jquery or xmlthhpRequest) for JSON post? I couldn't make it work. Do yo have some example?

Which is the best way to use JSON examples through browser?

thanks a lot
Regards
Pablo

Crashing unexpected

Environment:

  • Win7
  • boost 1.59
  • VS 2015 community

Both, the http_example and my application, which implements more or less similiar the default_resource example are crashing unexpected when a request appears.

Most times VS sais there was a exception in 'ucrtbase.dll' / 'ucrtbased.dll'. Sometimes it points towards the first statement in default_resource lambda to be executed next.

Commenting those lines, solves the problem somehow:

if(length>buffer_size) {
    vector<char> buffer(buffer_size);
    size_t read_length;
    while((read_length=ifs.read(&buffer[0], buffer_size).gcount())>0) {
        response.stream.write(&buffer[0], read_length);
        response << HttpServer::flush;
    }
}

I will test you're new commit in the evening.

core dump when running the example

#0 0x00007f7eaee9c989 in raise () from /lib64/libc.so.6
#1 0x00007f7eaee9e098 in abort () from /lib64/libc.so.6
#2 0x00007f7eaf9bc9d5 in __gnu_cxx::__verbose_terminate_handler() () from /lib64/libstdc++.so.6
#3 0x00007f7eaf9ba946 in ?? () from /lib64/libstdc++.so.6
#4 0x00007f7eaf9ba973 in std::terminate() () from /lib64/libstdc++.so.6
#5 0x00007f7eaf9bab9f in __cxa_throw () from /lib64/libstdc++.so.6
#6 0x00007f7eafa0fb15 in std::__throw_regex_error(std::regex_constants::error_type) () from /lib64/libstdc++.so.6
#7 0x00000000004213ce in std::__detail::_Compiler<char const*, std::regex_traits >::_M_bracket_expression (

this=this@entry=0x7fff64f7e9e0) at /usr/include/c++/4.8.2/bits/regex_compiler.h:974

#8 0x0000000000421552 in std::__detail::_Compiler<char const*, std::regex_traits >::_M_atom (this=this@entry=0x7fff64f7e9e0)

at /usr/include/c++/4.8.2/bits/regex_compiler.h:960

#9 0x0000000000421943 in _M_term (this=this@entry=0x7fff64f7e9e0) at /usr/include/c++/4.8.2/bits/regex_compiler.h:795
#10 std::__detail::_Compiler<char const*, std::regex_traits >::_M_alternative (this=this@entry=0x7fff64f7e9e0)

at /usr/include/c++/4.8.2/bits/regex_compiler.h:773

#11 0x0000000000421b34 in std::__detail::_Compiler<char const*, std::regex_traits >::_M_disjunction (this=0x7fff64f7e9e0)

at /usr/include/c++/4.8.2/bits/regex_compiler.h:758

#12 0x00000000004217cc in std::__detail::_Compiler<char const*, std::regex_traits >::_M_atom (this=this@entry=0x7fff64f7e9e0)

at /usr/include/c++/4.8.2/bits/regex_compiler.h:947

#13 0x0000000000421943 in _M_term (this=this@entry=0x7fff64f7e9e0) at /usr/include/c++/4.8.2/bits/regex_compiler.h:795
#14 std::__detail::_Compiler<char const*, std::regex_traits >::_M_alternative (this=this@entry=0x7fff64f7e9e0)

at /usr/include/c++/4.8.2/bits/regex_compiler.h:773

#15 0x00000000004219a7 in std::__detail::_Compiler<char const*, std::regex_traits >::_M_alternative (

this=this@entry=0x7fff64f7e9e0) at /usr/include/c++/4.8.2/bits/regex_compiler.h:776

#16 0x0000000000421b34 in std::__detail::_Compiler<char const*, std::regex_traits >::_M_disjunction (this=0x7fff64f7e9e0)

at /usr/include/c++/4.8.2/bits/regex_compiler.h:758

#17 0x0000000000421e2b in std::__detail::_Compiler<char const*, std::regex_traits >::_Compiler (this=0x7fff64f7e9e0,

__b=<optimized out>, __e=<optimized out>, __traits=..., __flags=<optimized out>) at /usr/include/c++/4.8.2/bits/regex_compiler.h:729

#18 0x00000000004222a9 in __compile<char const*, std::regex_traits > (__f=16, __t=..., __e=@0x7fff64f7e9d0: 0x42ee36 "",

__b=@0x7fff64f7e9b8: 0x42ee22 "^([^:/]+):?([0-9]*)$") at /usr/include/c++/4.8.2/bits/regex_compiler.h:1105

#19 std::basic_regex<char, std::regex_traits >::basic_regex (this=0x7fff64f7eb80, __p=0x42ee22 "^([^:/]+):?([0-9]*)$",

__f=<optimized out>) at /usr/include/c++/4.8.2/bits/regex.h:388

#20 0x000000000042256e in SimpleWeb::ClientBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_serviceboost::asio::ip::tcp > >::ClientBase (this=this@entry=0x7fff64f7ee90, host_port="localhost:8080", default_port=default_port@entry=80)

at client_http.hpp:133

#21 0x0000000000422a43 in SimpleWeb::Client<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_serviceboost::asio::ip::tcp > >::Client (this=0x7fff64f7ee90, server_port_path=...) at client_http.hpp:188

CMake fails due to missing libboost_coroutine on CentOS 7

CentOS 7 ships with Boost 1.53 which doesn't seem to contain libboost_coroutine. The headers are present but there is no lib. I assume this was added between 1.53 and 1.55.

The boost version check in CMakeLists.txt is 1.41 - I guess this should be updated to 1.55 to give a better user warning.

Stack corruption?

I've been experiencing stack and heap collisions with my software and I've narrowed it down to server_http.hpp. Running valgrind with the following parameters reports some extremely large stack usage on my software and explains why I am consistently crashing in the same spot.

I decided to run the same check on the http_examples.cpp and found extremely high usage of the stack as well. By the way I want to thank you for creating this simple but yet elegant library, it was exactly what I was looking for to serve REST/HTML web services for my project.

Lastly, I run your library on both OSX and Linux and the crash only occurs on Linux. I will have to install and run valgrind on OSX and see if the stack behavior is the same on apple.

valgrind --log-file=valgrind.log --leak-check=full --track-origins=yes --show-reachable=yes ./http_examples

==3641== Memcheck, a memory error detector
==3641== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==3641== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==3641== Command: ./http_examples
==3641== Parent PID: 2733
==3641==
==3641== Warning: client switching stacks? SP change: 0x7aed548 --> 0x4036f98
==3641== to suppress, use: --max-stackframe=61564336 or greater
==3641== Warning: client switching stacks? SP change: 0x4036d98 --> 0x7aed550
==3641== to suppress, use: --max-stackframe=61564856 or greater
==3641== Warning: client switching stacks? SP change: 0x7aed508 --> 0x4036da0
==3641== to suppress, use: --max-stackframe=61564776 or greater
==3641== further instances of this message will not be shown.
==3641==

How do I establish an HTTPS connection with the HttpsClient verify_certificate set to true?

While there is the https_examples.cpp that shows how to create a HTTPS server properly, the HTTPS client defined in that particular example sets verify_certificate to false. Could you explain what the other parameters mean? I created a new SSL certificiate with a key but the final parameter asks for a verify_file; what does it refer to? A few helpful comments in the https portion of your system would really be helpful. Thank you.

Also, I got this error when i tried to pass the csr file created by openssl as the final parameter::

terminate called after throwing an instance of 'std::invalid_argument'
 what():  stoul

I am a bit confused

Is Simple-Web-Server (both client and server) Asynchronous or Multi-threaded?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.