Giter Site home page Giter Site logo

ipkn / crow Goto Github PK

View Code? Open in Web Editor NEW
7.4K 301.0 885.0 875 KB

Crow is very fast and easy to use C++ micro web framework (inspired by Python Flask)

License: BSD 3-Clause "New" or "Revised" License

CMake 1.34% C++ 75.70% Python 0.92% C 22.01% Makefile 0.03%
crow c-plus-plus webserver header-only

crow's People

Contributors

acron0 avatar alibitek avatar boodkb avatar bryce-anderson avatar chaomai avatar d-led avatar deliciousgarfield avatar erikaldsund avatar gabrielbiga avatar gmaisto avatar ipkn avatar jaewooseo avatar jcoffin01 avatar kumagi avatar martiuk avatar nakosung avatar philave avatar pierobot avatar rasie1 avatar rayburgemeestre avatar roxma avatar samuelmarks avatar sgiurgiu avatar sivachandran avatar thedrow avatar timocov avatar vadz avatar vbalien avatar whoshuu avatar xenosoz 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

crow's Issues

Issue with pathes & including css + javascript?

I'm trying to build a simple web app that's structured like this:

main.cpp
public/
    css/
        style.css
    img/
        test.png
    js/
        test.js
    templates/
        about.html
        blog.html
        index.html
vendor/
    crow_all.h
    mustache.h
    mustache.cpp
main.dSYM
makefile
main

However, I can't get the imports to work for the life of me. For example, I've tried several variations of the path within this href tag, but it constantly returns a 404 error when locating the style.css file. I've loaded this project into Apache, and it works totally fine. Any ideas?

<link rel="stylesheet" type="text/css" href="./public/css/style.css"/>

Main.cpp:

int main()
{
    crow::SimpleApp app;
    crow::mustache::set_base(".");

    CROW_ROUTE(app, "/")
    ([](){
        crow::mustache::context ctx;
        return crow::mustache::load("public/templates/index.html").render();
    });

    CROW_ROUTE(app, "/about")
    ([](){
        return crow::mustache::load("public/templates/about.html").render();;
    });

    CROW_ROUTE(app, "/github")
    ([](){
        return crow::mustache::load("").render();;
    });
}

Why the custom JSON library?

A custom JSON library feels out of place in crow. Was it specifically for performance? C++11/14 features? Header only?

It makes more sense that crow would focus on being a web framework and look to other libraries for providing JSON, especially considering the number of JSON libraries for C++. Furthermore, it would be comforting to use a JSON library which has extensive unit tests.

To help make my point, here's a list of (some) C++ JSON libraries (one of which is my own): https://github.com/fffaraz/awesome-cpp#json

Upload file via HTTP

Hello all. Congrats for amazing project!

I need to know how i do one file upload with HTML form and save the file in my backend with crow.

Thanks.

Failed to build on clang 3. 6

I am trying to build all the examples with clang 3.6 and I can see the CC/ CXX has been found properly by using clang 3.6.

However it failed to find c++ 11 headers.

Error is like :

'future' file not found

I did some google, and it seems that the libstdc++ is not specified properly, or some people reckon I should build the clang libstdc++ myself.

Anyone can shed some light on this will be much appreciated.

Benchmark needed

Need to compare the performance with another API server frameworks. (It will be better if there's automated benchmark integrated into CI.)

I think the benchmark should include go, play, node.js (express). Comparing with nginx static page for the performance index would be good.

We can use ab or wrk to test concurrent request.

What do you need? (Roadmap?)

Hi,

Really keen to contribute to this project, but is there anything you particularly need?

  • Middleware handling
  • Templating
  • Logging
  • Statics

Can't define same route for differents methods

Hi, I started to test crow, works fine but when I try to do the following :


    CROW_ROUTE(app,"/db/<string>")
    .methods("GET"_method)
    ([](string dbName){
       return crow::response(200);
    });

    CROW_ROUTE(app,"/db/<string>")
    .methods("PUT"_method)
    ([](string dbName){
       return crow::response(200);
    });

    CROW_ROUTE(app,"/db/<string>")
    .methods("DELETE"_method)
    ([](string dbName){
       return crow::response(200);
    });

it throw an exception "handler already exists for /db/"

Why I can't use the same route but for differents methods ? Is this normal ?

Thank's

Idiomatic middleware

It's unclear what the most idiomatic way of writing middleware for crow is.

  • Is a middleware context structure shared across requests, or is a new object created for each new request?
  • What is the preferred way of setting parameters on a middleware objects, now that the new mechanism prevents us from using constructors?

Documentation

I think implementing basic features is done and writing documentation is high priority now.

  1. Create Quickstart page.
  2. Create a page for detailed topic.

The build guide document need improve, boost library required by crow

Can not make due to require boost library
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- No build type selected, default to Release
CMake Error at /usr/share/cmake-3.0/Modules/FindBoost.cmake:1199 (message):
Unable to find the requested Boost libraries.

Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:18 (find_package)

Server hits a wall at ~16384 connections

Hi there! Pardon me if I am making a simple mistake, but I have been benchmarking a Crow server using Apache Bench (ab), and I seem to be predictably hitting a wall at slightly under 16384 connections (the number varies between 16340 and 16360, always just shy of 2**14). The server stays locked up for tens of seconds. I tested on a MacBook Pro using each of g++ 4.9 and clang++ 6.0.

Pasted below is a minimal test case and ab output. Any ideas?

Thanks! --pete

$ cat trivial-server.cpp
#include "crow_all.h"

int main() {
  crow::SimpleApp app;

  CROW_ROUTE(app, "/")
  ([](){
    return crow::response(200);
  });

  app.port(8080).multithreaded().run();
}

$ clang++ -o trivial-server -std=c++1y -lboost_system trivial-server.cpp

$ ./trivial-server 2>/dev/null &
[1] 2449

$ ab -n 20000 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests
Completed 8000 requests
Completed 10000 requests
Completed 12000 requests
Completed 14000 requests
Completed 16000 requests
apr_socket_recv: Operation timed out (60)
Total of 16358 requests completed

GCC version and dependencies

Under Gentoo Linux the dependent package is called google-perftools, we should keep that. And we should mention gcc needs to be >= 4.8.1.

Cannot build on MacOSX 10.10 (Yosemite)

Build failed on MacOSX 10.10 (Yosemite; beta).

Build Environment

  • uname -a: Darwin hermes 14.0.0 Darwin Kernel Version 14.0.0: Sat Sep 27 03:58:47 PDT 2014; root:xnu-2782.1.97~11/RELEASE_X86_64 x86_64 i386 MacBookAir5,2 Darwin
  • clang: Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
  • boost: stable 1.56.0, HEAD (installed using homebrew)

Build log

[ 75%] Building CXX object examples/CMakeFiles/example_chat.dir/example_chat.cpp.o
/Users/rein/work/crow/examples/example_chat.cpp:18:15: error: use of overloaded
      operator '=' is ambiguous (with operand types 'crow::json::wvalue' and
      'size_type' (aka 'unsigned long'))
    x["last"] = msgs.size();
    ~~~~~~~~~ ^ ~~~~~~~~~~~
/Users/rein/work/crow/include/json.h:1118:21: note: candidate function
            wvalue& operator = (bool value)
                    ^
/Users/rein/work/crow/include/json.h:1128:21: note: candidate function
            wvalue& operator = (double value)
                    ^
/Users/rein/work/crow/include/json.h:1136:21: note: candidate function
            wvalue& operator = (uint16_t value)
                    ^
/Users/rein/work/crow/include/json.h:1144:21: note: candidate function
            wvalue& operator = (int16_t value)
                    ^
/Users/rein/work/crow/include/json.h:1152:21: note: candidate function
            wvalue& operator = (uint32_t value)
                    ^
/Users/rein/work/crow/include/json.h:1160:21: note: candidate function
            wvalue& operator = (int32_t value)
                    ^
/Users/rein/work/crow/include/json.h:1168:21: note: candidate function
            wvalue& operator = (uint64_t value)
                    ^
/Users/rein/work/crow/include/json.h:1176:21: note: candidate function
            wvalue& operator = (int64_t value)
                    ^
/Users/rein/work/crow/examples/example_chat.cpp:47:19: error: use of overloaded
      operator '=' is ambiguous (with operand types 'crow::json::wvalue' and
      'size_type' (aka 'unsigned long'))
        x["last"] = msgs.size();
        ~~~~~~~~~ ^ ~~~~~~~~~~~
/Users/rein/work/crow/include/json.h:1118:21: note: candidate function
            wvalue& operator = (bool value)
                    ^
/Users/rein/work/crow/include/json.h:1128:21: note: candidate function
            wvalue& operator = (double value)
                    ^
/Users/rein/work/crow/include/json.h:1136:21: note: candidate function
            wvalue& operator = (uint16_t value)
                    ^
/Users/rein/work/crow/include/json.h:1144:21: note: candidate function
            wvalue& operator = (int16_t value)
                    ^
/Users/rein/work/crow/include/json.h:1152:21: note: candidate function
            wvalue& operator = (uint32_t value)
                    ^
/Users/rein/work/crow/include/json.h:1160:21: note: candidate function
            wvalue& operator = (int32_t value)
                    ^
/Users/rein/work/crow/include/json.h:1168:21: note: candidate function
            wvalue& operator = (uint64_t value)
                    ^
/Users/rein/work/crow/include/json.h:1176:21: note: candidate function
            wvalue& operator = (int64_t value)
                    ^
/Users/rein/work/crow/examples/example_chat.cpp:60:23: error: use of overloaded
      operator '=' is ambiguous (with operand types 'crow::json::wvalue' and
      'size_type' (aka 'unsigned long'))
            x["last"] = msgs.size();
            ~~~~~~~~~ ^ ~~~~~~~~~~~
/Users/rein/work/crow/include/json.h:1118:21: note: candidate function
            wvalue& operator = (bool value)
                    ^
/Users/rein/work/crow/include/json.h:1128:21: note: candidate function
            wvalue& operator = (double value)
                    ^
/Users/rein/work/crow/include/json.h:1136:21: note: candidate function
            wvalue& operator = (uint16_t value)
                    ^
/Users/rein/work/crow/include/json.h:1144:21: note: candidate function
            wvalue& operator = (int16_t value)
                    ^
/Users/rein/work/crow/include/json.h:1152:21: note: candidate function
            wvalue& operator = (uint32_t value)
                    ^
/Users/rein/work/crow/include/json.h:1160:21: note: candidate function
            wvalue& operator = (int32_t value)
                    ^
/Users/rein/work/crow/include/json.h:1168:21: note: candidate function
            wvalue& operator = (uint64_t value)
                    ^
/Users/rein/work/crow/include/json.h:1176:21: note: candidate function
            wvalue& operator = (int64_t value)
                    ^
3 errors generated.
make[2]: *** [examples/CMakeFiles/example_chat.dir/example_chat.cpp.o] Error 1
make[1]: *** [examples/CMakeFiles/example_chat.dir/all] Error 2
make: *** [all] Error 2

Compilation broken

Hiya,

Was working on my TravisCI branch, pulled the latest and observed this error:
https://travis-ci.org/acron0/crow/builds/34990803

/home/travis/build/acron0/crow/include/parser.h:133:99: error: no matching function for call to ‘crow::request::request(<brace-enclosed initializer list>)’
    return request{(HTTPMethod)method, std::move(url), std::move(headers), std::move(body)};

Oddly, it appears that this line in parser.h isn't new, so I can only assue it's down to the change in 9eb96b7 (9eb96b7#diff-28391937b3fa1a9bab4fb2f58cc7ea15L11) with regards to ci_map

I've made a fix on this branch which may be the preferred approach but...want to get some advice on it, really:

https://github.com/acron0/crow/blob/travis-ci/include/parser.h#L131-L139

Update
Possible fix? http://stackoverflow.com/questions/4118025/brace-enclosed-initializer-list-constructor

MSVC support

Crow uses the following features that are still not supported in MSVC (v120 - Visual Studio 2013):

  • constexpr
  • noexcept
  • thread_local (partial support using __declspec(thread))
  • User defined literals

Any others?

Production ready?

I was considering a possibility of using this in production? It seems to have all the stuff I currently need. Is there are a reason why I should not use it? Memory leaks or sort?

Thank you

Project description

Wouldn't it be better to change the project description to:
"Crow is C++ micro web framework (inspired by Python Flask)"
or
"Crow is C++ micro framework for the Web (inspired by Python Flask)"

Instead of "Crow is C++ Microframework for Web (inspired by Python Flask)"

100% CPU usage

I am not sure whether this is caused by crow, when I use crow.h sometimes my program takes 100% CPU and couldn't respond to requests, but this doesn't happen when I use crow_all.h, previously you were fixing the bug in http_parser_merged and but this bug is not fixed in crow_all.h, I am wondering whether some bug was introduced during that fix.

Check if json request parameter exist

Hi,
I use crow for a basic web-service to manage DB, and I would like to know if it's possible to test existence of a parameters in request body.

For example, I have this code:

        else  if (req.method == "POST"_method) 
        {
            auto x = crow::json::load(req.body);
            if (!x)
                return crow::response(400, BADREQUEST);
            if (!x["db"]) //Parameter key to test
                return crow::response(404, DBNOTFOUND);
         }

But it's always return 500 Internal server error with this message in log: An uncaught exception occurred: cannot find key.

Is it possible to test if parameter key exist ?

Thanks

Implementing missing HTTP/1.1 features

  • Handling Transfer-Encoding: chunked
  • Timeout (and make it configurable)
  • Handling methods properly (at least HEAD, OPTIONS)
  • Absolute URL
  • If-Modified-Since: and If-Unmodified-Since:

Remove CROW_ROUTE macro.

The desire is to move back to a simple method call that looks like

app.route("/hello/<int>", [](int count){ ... });

But to maintain compile-time checking of url parameters and argument lists.

IS_NUM name conflict with mysql++

In file included from amordad.cpp:46:0:
../common/crow_all.h:2898:0: warning: "IS_NUM"
redefined [enabled by default]
#define IS_NUM(c) ((c) >= '0' && (c) <=
^
In file included from /usr/include/mysql++/common.h:189:0,
from /usr/include/mysql++/connection.h:38,
from /usr/include/mysql++/mysql++.h:56,
from ../common/EngineDB.hpp:26,
from amordad.cpp:45:
/usr/include/mysql/mysql.h:90:0: note: this is
the location of the previous definition
#define IS_NUM(t) (((t) <= MYSQL_TYPE_INT24 && (t
^

boost::move and crow::move are making conflict at crow/tests/unittest.cpp

I've faced following error at compiling:

crow/tests/unittest.cpp:936:46: error: call of overloaded ‘move(const crow::query_string&)’ is ambiguous
last_url_params = move(req.url_params);

Compiler told me there are two candidates:

  1. move() from boost/move/utility_core.hpp
  2. move() from c++/4.9/bits/move.h

I resolve this with change 'last_url_params = move(req.url_params);' to 'last_url_params = std::move(req.url_params);' but still don't know which one is your intention.

thanks.

Get a logo

Some one needs to bribe an artist/designer to make a logo :)

Cannot build on mac OS X Yosemite

Build Log

[ 11%] Built target amalgamation
[ 22%] Built target example
[ 33%] Built target example_chat
[ 44%] Built target example_chat_copy
[ 55%] Built target example_copy
[ 66%] Built target example_with_all
[ 77%] Building CXX object tests/CMakeFiles/unittest.dir/unittest.cpp.o
/Users/julio/Projects/crow/tests/unittest.cpp:936:27: error: call to 'move' is
ambiguous
last_url_params = move(req.url_params);
^~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:1603:1: note:
candidate function [with _Tp = const crow::query_string &]
move(_Tp&& __t) _NOEXCEPT
^
/usr/local/include/boost/move/utility_core.hpp:191:77: note: candidate function
[with T = const crow::query_string &]
...inline typename ::boost::move_detail::remove_reference::type && move(...
^
1 error generated.
make[2]: *** [tests/CMakeFiles/unittest.dir/unittest.cpp.o] Error 1
make[1]: *** [tests/CMakeFiles/unittest.dir/all] Error 2
make: *** [all] Error 2

System Specifications

Boost version: 1.58.0

uname -a
Darwin MacBook-Pro-de-Julio-Cesar-Brito-Gardona.local 14.4.0 Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86

Trailing slash when matching routes

Currently a request to /hello/ will not match a route for /hello .

Do we want to...
a) leave it as it is - it's explicit and not uncommon behaviour
b) leave it up to middleware (a la django-unslashed)
c) attempt to match routes both with and without a trailing slash, if one is present?

merge_all.py

'print' is not compatible with python 3 and I met with another
'd = open(os.path.join(header_path, header)).read().decode('utf8')
AttributeError: 'str' object has no attribute 'decode''. I've tried to remove the '.decode('utf8')' and seemly solved it.
Beyond this issue, I finally met with 'crow/tests/unittest.cpp:936:46: error: call of overloaded ‘move(const crow::query_string&)’ is ambiguous
last_url_params = move(req.url_params);
^
'
build with GNU Make 4.1, g++ (GCC) 5.1.0, Python 3.4.3, boost 1.58.0 on archlinux with kernel version 4.0.5, x86_64 arch

Crash report

crow rarely crashes during my test.

(gdb) run
Starting program: /home/ubuntu/crow/examples/example
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff6dd2700 (LWP 2961)]
[New Thread 0x7ffff65d1700 (LWP 2962)]
[New Thread 0x7ffff5dd0700 (LWP 2963)]
[New Thread 0x7ffff55cf700 (LWP 2964)]
[New Thread 0x7ffff4dce700 (LWP 2965)]
[New Thread 0x7fffe7fff700 (LWP 2966)]
[New Thread 0x7fffe77fe700 (LWP 2967)]
[New Thread 0x7fffe6ffd700 (LWP 2968)]
[New Thread 0x7fffe67fc700 (LWP 2969)]
[New Thread 0x7fffe5ffb700 (LWP 2970)]
[New Thread 0x7fffe57fa700 (LWP 2971)]
[New Thread 0x7fffe4ff9700 (LWP 2972)]
[New Thread 0x7fffc3fff700 (LWP 2973)]
[New Thread 0x7fffc37fe700 (LWP 2974)]
[New Thread 0x7fffc2ffd700 (LWP 2975)]
[New Thread 0x7fffc27fc700 (LWP 2976)]
[New Thread 0x7fffc1ffb700 (LWP 2977)]
[New Thread 0x7fffc17fa700 (LWP 2978)]
[New Thread 0x7fffc0ff9700 (LWP 2979)]
[New Thread 0x7fffa3fff700 (LWP 2980)]
[New Thread 0x7fffa37fe700 (LWP 2981)]
[New Thread 0x7fffa2ffd700 (LWP 2982)]
[New Thread 0x7fffa27fc700 (LWP 2983)]
[New Thread 0x7fffa1ffb700 (LWP 2984)]
[New Thread 0x7fffa17fa700 (LWP 2985)]
[New Thread 0x7fffa0ff9700 (LWP 2986)]
[New Thread 0x7fff83fff700 (LWP 2987)]
[New Thread 0x7fff837fe700 (LWP 2988)]
[New Thread 0x7fff82ffd700 (LWP 2989)]
[New Thread 0x7fff827fc700 (LWP 2990)]
[New Thread 0x7fff81ffb700 (LWP 2991)]
[New Thread 0x7fff817fa700 (LWP 2992)]
[New Thread 0x7fff80ff9700 (LWP 2993)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff83fff700 (LWP 2987)]
0x000000000043fccc in crow::Connection<crow::Crow<ExampleMiddleware>, ExampleMiddleware>::start_deadline(int) ()
(gdb) where
#0  0x000000000043fccc in crow::Connection<crow::Crow<ExampleMiddleware>, ExampleMiddleware>::start_deadline(int) ()
#1  0x0000000000442835 in boost::asio::detail::reactive_socket_recv_op<boost::asio::mutable_buffers_1, crow::Connection<crow::Crow<ExampleMiddleware>, ExampleMiddleware>::do_read()::{lambda(boost::system::error_code const&, unsigned long)#1}>::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long) ()
#2  0x00000000004357f4 in boost::asio::detail::task_io_service::run(boost::system::error_code&) ()
#3  0x0000000000440894 in crow::Server<crow::Crow<ExampleMiddleware>, ExampleMiddleware>::run()::{lambda()#1}::operator()() const ()
#4  0x000000000042a95a in std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, void> >::_M_invoke(std::_Any_data const&) ()
#5  0x0000000000429b0e in std::__future_base::_State_base::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>&, bool&) ()
#6  0x00007ffff79c5a90 in pthread_once () from /lib/x86_64-linux-gnu/libpthread.so.0
#7  0x0000000000446a31 in std::thread::_Impl<std::_Bind_simple<std::__future_base::_Async_state_impl<std::_Bind_simple<crow::Server<crow::Crow<ExampleMiddleware>, ExampleMiddleware>::run()::{lambda()#1} ()>, void>::_Async_state_impl(crow::Server<crow::Crow<ExampleMiddleware>, ExampleMiddleware>::run()::{lambda()#1} (&&)())::{lambda()#1} ()> >::_M_run() ()
#8  0x00007ffff7765bf0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#9  0x00007ffff79c0182 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#10 0x00007ffff6ecd47d in clone () from /lib/x86_64-linux-gnu/libc.so.6
(gdb)

here is my test.

# ./wrk -t8 -c1024 -d10s "http://10.254.134.159:18080/json"
Running 10s test @ http://10.254.134.159:18080/json
  8 threads and 1024 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     7.86ms   29.81ms 228.87ms   98.10%
    Req/Sec     9.95k     7.82k   28.03k    75.00%
  23734 requests in 10.02s, 3.46MB read
  Socket errors: connect 11, read 70, write 0, timeout 0
Requests/sec:   2368.97
Transfer/sec:    353.96KB

Allow to store response object for long polling and more

Allow handlers to have a prototype:

(crow::response res, <variable arguments>)
(crow::request req, crow::response res, <variable arguments>)

When stored res object is destroyed or its .end() method is called, the HTTP response is sent.

res object should store a link to the internal connection object.

Large build time. Time to create a dylib?

How can I reduce the build time of my application with Crow?

Is possible create a dynamic lib of Crow?

I created one precompiled header of crow.h -> .h.gch, but not improved much.

I'm using clang llvm compiler.

Any idea?

implement arena allocator to boost performance

http://en.wikipedia.org/wiki/Region-based_memory_management

Any request based server can take benefits from the region based allocator because there's no interaction between threads and it has the better locality.

Todos:

  • implement custom string class (crow::string) based on region allocator
  • check for another optimizations for json and mustache
  • compare the benchmark result with std::string + tcmalloc version

I think it is enough to supply a custom allocator for unordered_map because the user will read values rom container in many cases.

independent crow method to parse encoded url?

I want to use crow to query/, the string here is a path like "/usr/local/something.txt", I don't want to use crow::request, is there an independent method to call to parse the encoded url ("%20usr%20local%20something.txt) and return the path for me. Thank you for your help in advance.

URL query string parse crash

I wrote a forum https://leanclub.org using crow , but it crash every 10 minutes , so I use gdb to get the trace

(gdb) backtrace
#0  0x00007ffff5b3b528 in _int_free (av=0x7fffc4000020, p=<optimized out>, have_lock=0) at malloc.c:3996
#1  0x000000000057df86 in __gnu_cxx::new_allocator<char*>::deallocate (this=0x7fffe00148c0, __p=0x7fffc4014f20)
    at /usr/include/c++/4.9/ext/new_allocator.h:110
#2  0x000000000057734d in std::allocator_traits<std::allocator<char*> >::deallocate (__a=..., __p=0x7fffc4014f20, __n=256)
    at /usr/include/c++/4.9/bits/alloc_traits.h:383
#3  0x000000000056efbe in std::_Vector_base<char*, std::allocator<char*> >::_M_deallocate (this=0x7fffe00148c0, __p=0x7fffc4014f20, __n=256)
    at /usr/include/c++/4.9/bits/stl_vector.h:178
#4  0x0000000000565fc3 in std::_Vector_base<char*, std::allocator<char*> >::~_Vector_base (this=0x7fffe00148c0, __in_chrg=<optimized out>)
    at /usr/include/c++/4.9/bits/stl_vector.h:160
#5  0x000000000055e5fb in std::vector<char*, std::allocator<char*> >::~vector (this=0x7fffe00148c0, __in_chrg=<optimized out>)
    at /usr/include/c++/4.9/bits/stl_vector.h:425
#6  0x00000000005484da in crow::query_string::~query_string (this=0x7fffe00148b8, __in_chrg=<optimized out>)
    at /home/typcncom_gmail_com/leanclub/include/query_string.h:238
#7  0x000000000057cb1e in crow::HTTPParser<crow::Connection<crow::Crow<>> >::~HTTPParser() (this=0x7fffe0014838, __in_chrg=<optimized out>)
    at /home/typcncom_gmail_com/leanclub/include/parser.h:15
#8  0x00000000005889b2 in crow::Connection<crow::Crow<>>::~Connection() (this=0x7fffe0013810, __in_chrg=<optimized out>)
    at /home/typcncom_gmail_com/leanclub/include/http_connection.h:213
#9  0x0000000000585bcf in crow::Connection<crow::Crow<>>::check_destroy() (this=0x7fffe0013810)
    at /home/typcncom_gmail_com/leanclub/include/http_connection.h:502
#10 0x00000000005823c1 in crow::Connection<crow::Crow<>>::do_read()::{lambda(boost::system::error_code const&, unsigned long)#1}::operator()(boost::system::error_code const&, unsigned long) const (__closure=0x7fffb7fe65a0, ec=..., bytes_transferred=0)
    at /home/typcncom_gmail_com/leanclub/include/http_connection.h:456
#11 0x000000000059349a in boost::asio::detail::binder2<crow::Connection<crow::Crow<>>::do_read()::{lambda(boost::system::error_code const&, unsigned long)#1}, boost::system::error_code, unsigned long>::operator()() (this=0x7fffb7fe65a0) at /usr/include/boost/asio/detail/bind_handler.hpp:127
#12 0x0000000000591ec4 in boost::asio::asio_handler_invoke<boost::asio::detail::binder2<crow::Connection<crow::Crow<>>::do_read()::{lambda(boost::system::error_code const&, unsigned long)#1}, boost::system::error_code, unsigned long> >(boost::asio::detail::binder2<crow::Connection<crow::Crow<>>::do_read()::{lambda(boost::system::error_code const&, unsigned long)#1}, boost::system::error_code, unsigned long>&, ...) (function=...)
    at /usr/include/boost/asio/handler_invoke_hook.hpp:69
#13 0x0000000000590719 in boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<crow::Connection<crow::Crow<>>::do_read()::{lambda(boost::system::error_code const&, unsigned long)#1}, boost::system::error_code, unsigned long>, {lambda(boost::system::error_code const&, unsigned long)#1}>(boost::asio::detail::binder2<crow::Connection<crow::Crow<>>::do_read()::{lambda(boost::system::error_code const&, unsigned long)#1}, boost::system::error_code, unsigned long>&, {lambda(boost::system::error_code const&, unsigned long)#1}&) (function=..., context=...) at /usr/include/boost/asio/detail/handler_invoke_helpers.hpp:37
---Type <return> to continue, or q <return> to quit---

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.