Coder Social home page Coder Social logo

nitrogen / simple_bridge Goto Github PK

View Code? Open in Web Editor NEW
112.0 10.0 76.0 3.48 MB

A simple, standardized interface library to Erlang HTTP Servers.

License: MIT License

Erlang 97.45% JavaScript 1.06% Makefile 1.48%
cowboy erlang inets mochiweb websocket websockets yaws

simple_bridge's Introduction

Nitrogen Web Framework for Erlang

Nitrogen is an Erlang-based web framework that allows you to develop infinitely scaleable, Ajax-rich web applications using a pure Erlang technology stack.

See the Nitrogen Project website for additional information.

Upgrading from Nitrogen 2 to Nitrogen 3?

If you are using a Nitrogen 2 structured project, run the following two commands from the root of your Nitrogen 2-based project.

WARNING: Make sure you commit to version control before running this - it will change your working directory heavily

WARNING 2: Running scripts directly from the internet is dumb. Review this script's code before you run it. But if you really want to do it this way, here you go.

curl -o https://raw.githubusercontent.com/nitrogen/nitrogen/master/scripts/upgrade_to_nitrogen3.sh
bash upgrade_to_nitrogen3.sh

The first line downloads the upgrade script to your local project directory

The second line runs that script

Getting Started

Follow the tutorial at http://nitrogenproject.com/doc/tutorial.html

Building Nitrogen on Linux and OSX

The Getting Started guide covers this.

Building Nitrogen on FreeBSD

Install Erlang from

Make sure you have gmake installed, and use gmake instead of make

Example:

$ gmake rel_cowboy

Building Nitrogen on Windows

Instructions for building on windows can be found in rel/overlay/win

Want to contribute?

nitrogen_core is where you would find the vast majority of Nitrogen's codebase, should you wish to contribute or make changes.

Read our contribution guidelines to get started contributing to Nitrogen! (they're not strict, just recommendations)

simple_bridge's People

Contributors

5ht avatar ad-pro avatar brigadier avatar bunnylushington avatar burbas avatar choptastic avatar danikp avatar davidw avatar dmsnell avatar drobakowski avatar etxemag75 avatar evanmiller avatar fenek avatar fooflare avatar gleber avatar hji avatar jlarky avatar meike-hecker avatar metok avatar mihawk avatar mrinalwadhwa avatar ngaranko avatar olivier-boudeville avatar rambocoder avatar romanshestakov avatar rustyio avatar stuart-thackray avatar tempaccounterl 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

simple_bridge's Issues

simple_bridge broken for cowboy 1.0.1

On an almost vanilla nitrogen setup with Otp21, cowboy 1.0.1 the code compiles fine,
but it fails when loading the runtime.

On the same topic. For me this is the last sane comit (for cowboy 1.0.1):
e209ea9
"Initial fixes to work with Erlang 21"

After this comit I get this error. (TRACE #1... there is another trace below this one)

Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:5] [hipe]

Eshell V10.0 (abort with ^G)
([email protected])1> Starting Cowboy Server on {0,0,0,0}:8000
Static Paths: ["js/","css/","images/","nitrogen/","favicon.ico"]
Document Root for Static: ./site/static
Using Cowboy Dispatch Table:
[{'',[],
[{[<<"js">>,'...'],
[],cowboy_static,
{dir,"./site/static/js/",[{mimetypes,cow_mimetypes,all}]}},
{[<<"css">>,'...'],
[],cowboy_static,
{dir,"./site/static/css/",[{mimetypes,cow_mimetypes,all}]}},
{[<<"images">>,'...'],
[],cowboy_static,
{dir,"./site/static/images/",[{mimetypes,cow_mimetypes,all}]}},
{[<<"nitrogen">>,'...'],
[],cowboy_static,
{dir,"./site/static/nitrogen/",[{mimetypes,cow_mimetypes,all}]}},
{[<<"favicon.ico">>],
[],cowboy_static,
{file,"./site/static/favicon.ico",[{mimetypes,cow_mimetypes,all}]}},
{'
',[],cowboy_simple_bridge_anchor,[]}]}]
=INFO REPORT==== 26-Dec-2018::16:17:02.459464 ===
application: simple_bridge
exited: {{undef,
[{cowboy,start_clear,
[http,
[{ip,{0,0,0,0}},{port,8000}],
#{env =>
#{dispatch =>
[{'',[],
[{[<<"js">>,'...'],
[],cowboy_static,
{dir,"./site/static/js/",
[{mimetypes,cow_mimetypes,all}]}},
{[<<"css">>,'...'],
[],cowboy_static,
{dir,"./site/static/css/",
[{mimetypes,cow_mimetypes,all}]}},
{[<<"images">>,'...'],
[],cowboy_static,
{dir,"./site/static/images/",
[{mimetypes,cow_mimetypes,all}]}},
{[<<"nitrogen">>,'...'],
[],cowboy_static,
{dir,"./site/static/nitrogen/",
[{mimetypes,cow_mimetypes,all}]}},
{[<<"favicon.ico">>],
[],cowboy_static,
{file,"./site/static/favicon.ico",
[{mimetypes,cow_mimetypes,all}]}},
{'
',[],cowboy_simple_bridge_anchor,[]}]}]},
max_keepalive => 100}],
[]},
{cowboy_simple_bridge_sup,init,1,
[{file,
"/home/fran/deploy_uber/web/lib/simple_bridge/src/cowboy_bridge_modules/cowboy_simple_bridge_sup.erl"},
{line,36}]},
{supervisor,init,1,[{file,"supervisor.erl"},{line,295}]},
{gen_server,init_it,2,[{file,"gen_server.erl"},{line,374}]},
{gen_server,init_it,6,[{file,"gen_server.erl"},{line,342}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,249}]}]},
{simple_bridge_app,start,[normal,[]]}}
type: temporary
pusher starting with proxy fun serviceworker:pusher_proxy/5
ephemeral starting...
Starting Sync (Automatic Code Compiler / Reloader)
Scanning source files...

BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution


On even more recent commits, the last 5 or so, I get this error (TRACE #2.. this is long)

Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:5] [hipe]

Eshell V10.0 (abort with ^G)
([email protected])1> Starting Cowboy Server on {0,0,0,0}:8000
Static Paths: ["js/","css/","images/","nitrogen/","favicon.ico"]
Document Root for Static: ./site/static
Using Cowboy Dispatch Table:
[{'',[],
[{[<<"js">>,'...'],
[],cowboy_static,
{dir,"./site/static/js/",[{mimetypes,cow_mimetypes,all}]}},
{[<<"css">>,'...'],
[],cowboy_static,
{dir,"./site/static/css/",[{mimetypes,cow_mimetypes,all}]}},
{[<<"images">>,'...'],
[],cowboy_static,
{dir,"./site/static/images/",[{mimetypes,cow_mimetypes,all}]}},
{[<<"nitrogen">>,'...'],
[],cowboy_static,
{dir,"./site/static/nitrogen/",[{mimetypes,cow_mimetypes,all}]}},
{[<<"favicon.ico">>],
[],cowboy_static,
{file,"./site/static/favicon.ico",[{mimetypes,cow_mimetypes,all}]}},
{'
',[],cowboy_simple_bridge_anchor,[]}]}]
pusher starting with proxy fun serviceworker:pusher_proxy/5
ephemeral starting...
Starting Sync (Automatic Code Compiler / Reloader)
Scanning source files...
=ERROR REPORT==== 26-Dec-2018::16:12:20.306005 ===
Error in simple_bridge:make/2 - error - function_clause
[{sbw,'-cache_headers/1-lc$^0/1-0-',
[{[{<<"host">>,<<"localhost:8000">>},
{<<"connection">>,<<"Upgrade">>},
{<<"pragma">>,<<"no-cache">>},
{<<"cache-control">>,<<"no-cache">>},
{<<"user-agent">>,
<<"Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1">>},
{<<"upgrade">>,<<"websocket">>},
{<<"origin">>,<<"http://localhost:8000">>},
{<<"sec-websocket-version">>,<<"13">>},
{<<"accept-encoding">>,<<"gzip, deflate, br">>},
{<<"accept-language">>,<<"en-US,en;q=0.9">>},
{<<"cookie">>,
<<"fossil_display_settings=n%3D50%2Css%3Dx%2Cadvm%3D0%2Cy%3Dci">>},
{<<"sec-websocket-key">>,<<"Sasj5q6ZCDzuG3IYu0qONg==">>},
{<<"sec-websocket-extensions">>,
<<"permessage-deflate; client_max_window_bits">>}],
{http_req,#Port<0.16>,ranch_tcp,keepalive,<0.1501.0>,<<"GET">>,
'HTTP/1.1',
{{127,0,0,1},44600},
<<"localhost">>,undefined,8000,<<"/login">>,undefined,<<>>,
undefined,[],
[{<<"host">>,<<"localhost:8000">>},
{<<"connection">>,<<"Upgrade">>},
{<<"pragma">>,<<"no-cache">>},
{<<"cache-control">>,<<"no-cache">>},
{<<"user-agent">>,
<<"Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1">>},
{<<"upgrade">>,<<"websocket">>},
{<<"origin">>,<<"http://localhost:8000">>},
{<<"sec-websocket-version">>,<<"13">>},
{<<"accept-encoding">>,<<"gzip, deflate, br">>},
{<<"accept-language">>,<<"en-US,en;q=0.9">>},
{<<"cookie">>,
<<"fossil_display_settings=n%3D50%2Css%3Dx%2Cadvm%3D0%2Cy%3Dci">>},
{<<"sec-websocket-key">>,<<"Sasj5q6ZCDzuG3IYu0qONg==">>},
{<<"sec-websocket-extensions">>,
<<"permessage-deflate; client_max_window_bits">>}],
[{<<"sec-websocket-extensions">>,
[{<<"permessage-deflate">>,
[<<"client_max_window_bits">>]}]},
{<<"upgrade">>,[<<"websocket">>]},
{<<"connection">>,[<<"upgrade">>]}],
undefined,
[{websocket_version,13},{websocket_compress,false}],
waiting,<<>>,undefined,false,waiting,[],<<>>,undefined}}],
[{file,"/home/fran/deploy_uber/web/lib/simple_bridge/src/sbw.erl"},
{line,121}]},
{sbw,cache_headers,1,
[{file,"/home/fran/deploy_uber/web/lib/simple_bridge/src/sbw.erl"},
{line,121}]},
{sbw,new,2,
[{file,"/home/fran/deploy_uber/web/lib/simple_bridge/src/sbw.erl"},
{line,102}]},
{simple_bridge,make_nocatch,2,
[{file,"/home/fran/deploy_uber/web/lib/simple_bridge/src/simple_bridge.erl"},
{line,94}]},
{simple_bridge,inner_make,2,
[{file,"/home/fran/deploy_uber/web/lib/simple_bridge/src/simple_bridge.erl"},
{line,86}]},
{cowboy_simple_bridge_anchor,websocket_init,3,
[{file,"/home/fran/deploy_uber/web/lib/simple_bridge/src/cowboy_bridge_modules/cowboy_simple_bridge_anchor.erl"},
{line,43}]},
{cowboy_websocket,handler_init,3,
[{file,"src/cowboy_websocket.erl"},{line,131}]},
{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,442}]}]
=ERROR REPORT==== 26-Dec-2018::16:12:20.309883 ===
Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.1501.0> exit with reason: {[{reason,function_clause},{mfa,{cowboy_simple_bridge_anchor,websocket_init,3}},{stacktrace,[{simple_bridge,inner_make,2,[{file,"/home/fran/deploy_uber/web/lib/simple_bridge/src/simple_bridge.erl"},{line,89}]},{cowboy_simple_bridge_anchor,websocket_init,3,[{file,"/home/fran/deploy_uber/web/lib/simple_bridge/src/cowboy_bridge_modules/cowboy_simple_bridge_anchor.erl"},{line,43}]},{cowboy_websocket,handler_init,3,[{file,"src/cowboy_websocket.erl"},{line,131}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,442}]}]},{req,[{socket,#Port<0.16>},{transport,ranch_tcp},{connection,keepalive},{pid,<0.1501.0>},{method,<<"GET">>},{version,'HTTP/1.1'},{peer,{{127,0,0,1},44600}},{host,<<"localhost">>},{host_info,undefined},{port,8000},{path,<<"/login">>},{path_info,undefined},{qs,<<>>},{qs_vals,undefined},{bindings,[]},{headers,[{<<"host">>,<<"localhost:8000">>},{<<"connection">>,<<"Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"user-agent">>,<<"Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1">>},{<<"upgrade">>,<<"websocket">>},{<<"origin">>,<<"http://localhost:8000">>},{<<"sec-websocket-version">>,<<"13">>},{<<"accept-encoding">>,<<"gzip, deflate, br">>},{<<"accept-language">>,<<"en-US,en;q=0.9">>},{<<"cookie">>,<<"fossil_display_settings=n%3D50%2Css%3Dx%2Cadvm%3D0%2Cy%3Dci">>},{<<"sec-websocket-key">>,<<"Sasj5q6ZCDzuG3IYu0qONg==">>},{<<"sec-websocket-extensions">>,<<"permessage-deflate; client_max_window_bits">>}]},{p_headers,[{<<"sec-websocket-extensions">>,[{<<"permessage-deflate">>,[<<"client_max_window_bits">>]}]},{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"upgrade">>]}]},{cookies,undefined},{meta,[{websocket_version,13},{websocket_compress,false}]},{body_state,waiting},{buffer,<<>>},{multipart,undefined},{resp_compress,false},{resp_state,waiting},{resp_headers,[]},{resp_body,<<>>},{onresponse,undefined}]},{opts,[]}],[{cowboy_websocket,handler_init,3,[{file,"src/cowboy_websocket.erl"},{line,149}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,442}]}]}

=ERROR REPORT==== 26-Dec-2018::16:12:20.309820 ===
Error in process <0.1501.0> on node '[email protected]' with exit value:
{[{reason,function_clause},
{mfa,{cowboy_simple_bridge_anchor,websocket_init,3}},
{stacktrace,
[{simple_bridge,inner_make,2,
[{file,
"/home/fran/deploy_uber/web/lib/simple_bridge/src/simple_bridge.erl"},
{line,89}]},
{cowboy_simple_bridge_anchor,websocket_init,3,
[{file,
"/home/fran/deploy_uber/web/lib/simple_bridge/src/cowboy_bridge_modules/cowboy_simple_bridge_anchor.erl"},
{line,43}]},
{cowboy_websocket,handler_init,3,
[{file,"src/cowboy_websocket.erl"},{line,131}]},
{cowboy_protocol,execute,4,
[{file,"src/cowboy_protocol.erl"},{line,442}]}]},
{req,
[{socket,#Port<0.16>},
{transport,ranch_tcp},
{connection,keepalive},
{pid,<0.1501.0>},
{method,<<"GET">>},
{version,'HTTP/1.1'},
{peer,{{127,0,0,1},44600}},
{host,<<"localhost">>},
{host_info,undefined},
{port,8000},
{path,<<"/login">>},
{path_info,undefined},
{qs,<<>>},
{qs_vals,undefined},
{bindings,[]},
{headers,
[{<<"host">>,<<"localhost:8000">>},
{<<"connection">>,<<"Upgrade">>},
{<<"pragma">>,<<"no-cache">>},
{<<"cache-control">>,<<"no-cache">>},
{<<"user-agent">>,
<<"Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1">>},
{<<"upgrade">>,<<"websocket">>},
{<<"origin">>,<<"http://localhost:8000">>},
{<<"sec-websocket-version">>,<<"13">>},
{<<"accept-encoding">>,<<"gzip, deflate, br">>},
{<<"accept-language">>,<<"en-US,en;q=0.9">>},
{<<"cookie">>,
<<"fossil_display_settings=n%3D50%2Css%3Dx%2Cadvm%3D0%2Cy%3Dci">>},
{<<"sec-websocket-key">>,<<"Sasj5q6ZCDzuG3IYu0qONg==">>},
{<<"sec-websocket-extensions">>,
<<"permessage-deflate; client_max_window_bits">>}]},
{p_headers,
[{<<"sec-websocket-extensions">>,
[{<<"permessage-deflate">>,[<<"client_max_window_bits">>]}]},
{<<"upgrade">>,[<<"websocket">>]},
{<<"connection">>,[<<"upgrade">>]}]},
{cookies,undefined},
{meta,[{websocket_version,13},{websocket_compress,false}]},
{body_state,waiting},
{buffer,<<>>},
{multipart,undefined},
{resp_compress,false},
{resp_state,waiting},
{resp_headers,[]},
{resp_body,<<>>},
{onresponse,undefined}]},
{opts,[]}],
[{cowboy_websocket,handler_init,3,
[{file,"src/cowboy_websocket.erl"},{line,149}]},
{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,442}]}]}

SSL Cookie & other security configuration

Hi Jess; this is more of a question than pull request because I am not yet sure of answer,

I have to make X Y and Z changes due to security; anyways most involve returning headers specifically which have been done.

Part of it require only using certain ciphers ([{dhe_rsa,aes_256_cbc,sha256},{dhe_dss,aes_256_cbc,sha256},{rsa,aes_256_cbc,sha256},{dhe_rsa,aes_256_cbc,sha},{dhe_dss,aes_256_cbc,sha},{rsa,aes_256_cbc,sha}]) and configuration such as for yaws protocol version.
i.e. protocol_version = tlsv1.2, tlsv1.1, tlsv1
Both are done by the configuration of yaws.

Some require cookie changes to the cookie. I struggled a bit; I now almost there or closer.

    yaws_api:setcookie(Name, Value, Path, Expire).

to
yaws_api:setcookie(Name, Value, Path, Expire, Domian,Security = on).

This would almost work for me (but I am missing httponly flag). Which in yaws (1.99) is done by the following

%% @doc Generate a set_cookie header field tuple.
%% This function is more RFC6265 compliant than setcookie/6 and
%% therefore it deprecates setcookie/6 completely.
set_cookie(Key, Value, Options)

So my question is I have been using yaws for many years now. that is what I use; I know how to alter simple_bridge and other things with the head version to how I need.

So these cookie changes and default headers would there be any point of me doing a pull request for as probably requires some additional processing and maybe a specific usage case in my case? Upgrading of the yaws version of course as SSL protocol versions wasn't configurable before 1.99 (but I pull yaws from my own machine) rather than get-deps; but this is very simple.

I hope my question makes sense. If not please ask.

Req:deep_post_params() raise Error.

Module: xyadmin_email_controller, Line: 22, 
My print's "Req : post_params ( )" is [{"title","dsfasdfasdf"},
                                       {"serverlists[]","2"},
                                       {"users",[]},
                                       {"content","asdfasdfasdf"},
                                       {"attachments[0][item_type]","1"},
                                       {"attachments[0][item_id]","1"},
                                       {"attachments[0][item_name]","1"},
                                       {"attachments[0][item_amount]","1"},
                                       {"attachments[1][item_type]","2"},
                                       {"attachments[1][item_id]","1"},
                                       {"attachments[1][item_name]","1"},
                                       {"attachments[1][item_amount]","1"}]

How can i get the "attachments"?
I tried Req:param_group("attachments[]"), Req:post_param("attachments"), Req:post_param_group("attachments[]")

Req:deep_post_params() and Req:deep_post_param("attachments") will raise Error:
[error] Error in controller error:{case_clause,nomatch} Stacktrace: [{simple_bridge_request_wrapper,parse_deep_post_params,3,[{file,"src/simple_bridge_request_wrapper.erl"},{line,148}]},{xyadmin_email_controller,send,4,[{file,"/home/dcy/xyadmin/src/controller/xyadmin_email_controller.erl"},{line,30}]},{boss_web_controller,call_controller_action,3,[{file,"src/boss/boss_web_controller.erl"},{line,316}]},{boss_web_controller,apply_action,4,[{file,"src/boss/boss_web_controller.erl"},{line,308}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,287}]},{boss_web_controller_handle_request,process_dynamic_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,254}]},{boss_web_controller_handle_request,process_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,240}]},{boss_web_controller_handle_request,set_timer,8,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,160}]}]

It also at ChicagoBoss/ChicagoBoss#576

build_response forces Expires header?

Hi,

I've been encountering some trouble with static content being cached in ChicagoBoss ( ChicagoBoss/ChicagoBoss#229 ) and part of my digging led me to this code, in which the Expires header is set, whether I like it or not:

        ExpireDate = simple_bridge_util:expires(years, 10),
        %% Create the response telling Mochiweb to serve the file...
        Headers = [{"Expires", ExpireDate}, {"Cache-Control", "no-cache"}],

Shouldn't this be set somewhere else, rather than in code that's supposed to just make two other systems talk to one another?

Thank you

HTTP Basic Auth + at least yaws

Hi,

I have not had this problem in previous versions of simple bridge and yaws.

At least with a fresh pull of nitrogen & when you are trying to using HTTP Basic Auth it crashes. (Below is the crash).

For reference I was able to obtain the parameters i.e. username and password using the following code previously.

Headers = wf:headers(),
{value, {_, {UserName, Password, _}}} = lists:keysearch(authorization, 1, Headers),

I am not sure if this should be handled via sbw, yaws bridge modules or simple_bridge_util (i.e. I thought of adding "to_binary(T) when is_tuple(T) ->
T;" but this is probably not right. I will try another webserver and attempt to see if I get the same result.

=ERROR REPORT==== 25-Mar-2015::15:08:03 ===
Error in simple_bridge:make/2 - error - badarg
[{erlang,iolist_to_binary,
[{"stuart_airtime","psswd","Basic c3R1YXJ0X2FpcnRpbWU6cHNzd2Q="}],
[]},
{simple_bridge_util,to_binary,1,
[{file,"src/simple_bridge_util.erl"},{line,315}]},
{sbw,normalize_header,1,[{file,"src/sbw.erl"},{line,132}]},
{sbw,'-cache_headers/1-lc$^0/1-0-',1,[{file,"src/sbw.erl"},{line,120}]},
{sbw,'-cache_headers/1-lc$^0/1-0-',1,[{file,"src/sbw.erl"},{line,120}]},
{sbw,cache_headers,1,[{file,"src/sbw.erl"},{line,120}]},
{sbw,new,2,[{file,"src/sbw.erl"},{line,101}]},
{simple_bridge,make_nocatch,2,[{file,"src/simple_bridge.erl"},{line,94}]}]

DIR of temporary files is not created

Hi Jesse,

As this DIR isn't created (latest git), a call to wf_pandoc(…) fails with this error :

/var/tmp/scratch/tempfile_9999999999999999 openBinaryFile: does not exist (No such file or directory)

The following diffs are fixing that.
 
Move the scratch dir from "./scratch" (bad, where does it go?) to "/var/tmp/scratch" (good, well identified)
into: etc/simple_bridge.config

diff etc/simple_bridge.config_ORG etc/simple_bridge.config
45c45,46
<         {scratch_dir, "./scratch"}
---
> %%%%%%        {scratch_dir, "./scratch"}
>         {scratch_dir, "/var/tmp/scratch"}

BTW, there are a lot of useless space characters at the end of some lines in this file.
 
Check if the scratch DIR exist and if not, create it
into: lib/simple_bridge/src/simple_bridge_util.erl

diff simple_bridge_util.erl_ORG simple_bridge_util.erl
113c113,119
<         Other -> Other
---
>         %%%Other -> Other
>         Other ->
>             % +1 L: the DIR of temporaries is not auto-created, do it
>             %       otherwise a wf_pandoc(…) call will fail with :
>             %       openBinaryFile: does not exist (No such file or directory)
>             ok = filelib:ensure_dir(Other ++ "/"),
>             Other

Jean-Yves

dynamic routing yaws 404 (using default yaws_outmod)

Hi Jesse,

I am not sure if this is still a supported feature or if I am am supposed to write a custom (routing) handler to achieve it (haven't figured out yet what to do here). Happy to write a PR if this is a genuine issue; if you can suggest a way.

According to Nitrogen Tutorial under dynamic routing explained there point 4 states "Modules that aren't found go to web_404.erl if it exists."

https://github.com/nitrogen/simple_bridge/blob/master/src/yaws_bridge_modules/yaws_simple_bridge.erl#L186 is always called. I am not sure if this is with the introduction of websockets (done after the tutorial I believe).

Running dynamic and embedded yaws; specify the 404 module in the yaws.conf works fine for static paths; other default as shown the yaws default 404 module.

simple_bridge is not compatible with OTP R16B

As parameterized modules no longer exist in R16B, it fails with the following build error:

src/simple_bridge_response_wrapper.erl:5: parameterized modules are no longer supported

Add behavior which simply defines a handle(Req, Resp) function

The examples always contain the start/stop code for a single web server, so I still need to decide in my code, which webserver to use. What I would like to see is my code consisting of a handle(Req, Resp) function, which is called by some other module, ideally the request bridge. handle(Req, Resp) would then be the sole and web server independent entry point to my HTTP code.
A module similar to https://github.com/etnt/rebar_templates/blob/master/nitro_inets.erl could be part of simple_bridge, which adds the loopfunction for several web servers

Cowboy websocket error when changing page

I got this error, after creating a cowboy app, just clicking in the mobile sample link:

=ERROR REPORT==== 30-Sep-2014::01:01:07 ===
Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.214.0> exit with reason: {[{reason,undef},{mfa,{cowboy_simple_bridge_anchor,websocket_terminate,3}},{stacktrace,[{cowboy_simple_bridge_anchor,websocket_terminate,[{remote,1001,<<>>},{http_req,#Port<0.3893>,ranch_tcp,keepalive,<0.214.0>,<<"GET">>,'HTTP/1.1',{{127,0,0,1},36985},<<"localhost">>,undefined,8000,<<"/about">>,undefined,<<>>,undefined,[],[{<<"host">>,<<"localhost:8000">>},{<<"user-agent">>,<<"Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.1.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8">>},{<<"accept-language">>,<<"es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"dnt">>,<<"1">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost:8000">>},{<<"sec-websocket-key">>,<<"d+YikKQp6fvO+Q4mZl7Z8Q==">>},{<<"cookie">>,<<"__utma=111872281.300584001.1406903199.1412004910.1412029354.10; __utmz=111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); csrftoken=nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR; newcookie=A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg; __utmb=111872281.6.10.1412029354; __utmc=111872281">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"keep-alive">>,<<"upgrade">>]}],undefined,[{websocket_compress,false},{websocket_version,13}],waiting,undefined,<<>>,false,done,[],<<>>,undefined},{ws_state,nitrogen,{sbw,cowboy_simple_bridge,{cowboy_bridge,#Ref<0.0.0.311>},false,[],[],[],none,[{<<"host">>,<<"localhost:8000">>},{<<"user-agent">>,<<"Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.1.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8">>},{<<"accept-language">>,<<"es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"dnt">>,<<"1">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost:8000">>},{<<"sec-websocket-key">>,<<"d+YikKQp6fvO+Q4mZl7Z8Q==">>},{<<"cookie">>,<<"__utma=111872281.300584001.1406903199.1412004910.1412029354.10; __utmz=111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); csrftoken=nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR; newcookie=A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg; __utmb=111872281.6.10.1412029354; __utmc=111872281">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"__utma">>,<<"111872281.300584001.1406903199.1412004910.1412029354.10">>},{<<"__utmz">>,<<"111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)">>},{<<"csrftoken">>,<<"nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR">>},{<<"newcookie">>,<<"A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg">>},{<<"__utmb">>,<<"111872281.6.10.1412029354">>},{<<"__utmc">>,<<"111872281">>}],{response,200,[],[],[]}},undefined}],[]},{cowboy_websocket,handler_terminate,4,[{file,"src/cowboy_websocket.erl"},{line,761}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,529}]}]},{req,[{socket,#Port<0.3893>},{transport,ranch_tcp},{connection,keepalive},{pid,<0.214.0>},{method,<<"GET">>},{version,'HTTP/1.1'},{peer,{{127,0,0,1},36985}},{host,<<"localhost">>},{host_info,undefined},{port,8000},{path,<<"/about">>},{path_info,undefined},{qs,<<>>},{qs_vals,undefined},{bindings,[]},{headers,[{<<"host">>,<<"localhost:8000">>},{<<"user-agent">>,<<"Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.1.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8">>},{<<"accept-language">>,<<"es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"dnt">>,<<"1">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost:8000">>},{<<"sec-websocket-key">>,<<"d+YikKQp6fvO+Q4mZl7Z8Q==">>},{<<"cookie">>,<<"__utma=111872281.300584001.1406903199.1412004910.1412029354.10; __utmz=111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); csrftoken=nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR; newcookie=A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg; __utmb=111872281.6.10.1412029354; __utmc=111872281">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}]},{p_headers,[{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"keep-alive">>,<<"upgrade">>]}]},{cookies,undefined},{meta,[{websocket_compress,false},{websocket_version,13}]},{body_state,waiting},{multipart,undefined},{buffer,<<>>},{resp_compress,false},{resp_state,done},{resp_headers,[]},{resp_body,<<>>},{onresponse,undefined}]},{state,{ws_state,nitrogen,{sbw,cowboy_simple_bridge,{cowboy_bridge,#Ref<0.0.0.311>},false,[],[],[],none,[{<<"host">>,<<"localhost:8000">>},{<<"user-agent">>,<<"Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.1.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8">>},{<<"accept-language">>,<<"es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"dnt">>,<<"1">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost:8000">>},{<<"sec-websocket-key">>,<<"d+YikKQp6fvO+Q4mZl7Z8Q==">>},{<<"cookie">>,<<"__utma=111872281.300584001.1406903199.1412004910.1412029354.10; __utmz=111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); csrftoken=nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR; newcookie=A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg; __utmb=111872281.6.10.1412029354; __utmc=111872281">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"__utma">>,<<"111872281.300584001.1406903199.1412004910.1412029354.10">>},{<<"__utmz">>,<<"111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)">>},{<<"csrftoken">>,<<"nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR">>},{<<"newcookie">>,<<"A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg">>},{<<"__utmb">>,<<"111872281.6.10.1412029354">>},{<<"__utmc">>,<<"111872281">>}],{response,200,[],[],[]}},undefined}},{terminate_reason,{remote,1001,<<>>}}],[{cowboy_websocket,handler_terminate,4,[{file,"src/cowboy_websocket.erl"},{line,763}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,529}]}]}

=ERROR REPORT==== 30-Sep-2014::01:01:07 ===
Error in process <0.214.0> on node '[email protected]' with exit value: {[{reason,undef},{mfa,{cowboy_simple_bridge_anchor,websocket_terminate,3}},{stacktrace,[{cowboy_simple_bridge_anchor,websocket_terminate,[{remote,1001,<<0 bytes>>},{http_req,#Port<0.3893>,ranch_tcp,keepalive,<0.214.0>,<<3 bytes>>,'HTTP/1.1',{{127,0,0,1},36985},<<9 bytes>>,undefined...

The web pages work, but the error is launched in the console. This is the error in the browser:

TypeError: Obj.value is undefined
return this.BINARY + this.int_to_bytes(Obj.value.length, 4) + Obj.value; bert.js (line 209, col 1)

SSL PeerName YAWs

Hi,

Please could the peer_ip/1 function be updated to include support for SSL Sockets.

The Following code is the best way I could think to update for SSL sockets.

peer_ip(Arg) ->
Socket = socket(Arg),
case catch inet:peername(Socket) of
{ok, {IP, _Port}} ->
IP;
_ ->
{ok, {IP, _Port}} = ssl:peername(Socket)
end,
IP.

pmods usage

What do you think about me refactoring SB to not use Erlang's parametrized modules functionality and instead change the API to be:

RequestBridge = simple_bridge:make_request(mochiweb_response_bridge, [{Req, Docroot}]),
Method = simple_bridge_request:request_method(RequestBridge),
PeerIP = simple_bridge_request:peer_ip(RequestBridge).

Since pmods have been nuked from R15B02... Not sure if they are coming back in R16

cowboy_dispatch_function app configuration variable not honored

Simple bridge does not use the cowboy_dispatch_function mentioned in the sample configuration, but instead honors cowboy_dispatch_fun; either the code or the config file needs to be ammended.

I have no preference, but I think short names are better :)

See line 57 of src/cowboy_bridge_modules/cowboy_simple_bridge_sup.erl here:
https://github.com/nitrogen/simple_bridge/blob/cede863c96356a9f12c90976e3845d3f2c17710d/src/cowboy_bridge_modules/cowboy_simple_bridge_sup.erl#L57e

Inets: module traverse failed

I hope this time, I have checked everything I should (I think so). The handler error of yesterday have been fixed, but I still get this error in inets.log. In Firefox, I am getting each time I click a link, the line of the red panel in the top of the page all the time (in Chrome I can't see it):

[30/Oct/2014:10:40:01 +0100], module traverse failed: inets_simple_bridge_anchor:do =>
Error Type: exit
Error: normal
Stack trace: [{inets_simple_bridge_anchor,do,1,
[{file,
"src/inets_bridge_modules/inets_simple_bridge_anchor.erl"},
{line,16}]},
{httpd_response,traverse_modules,2,
[{file,"httpd_response.erl"},{line,72}]},
{httpd_response,generate_and_send_response,1,
[{file,"httpd_response.erl"},{line,40}]},
{httpd_request_handler,handle_response,1,
[{file,"httpd_request_handler.erl"},{line,527}]},
{gen_server,handle_msg,5,
[{file,"gen_server.erl"},{line,599}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,237}]}]

About sendfile funs

Sorry to pollute your ticket tracker but I can't seem to be able to send you an email, getting a DNS related error? Anyway here's what I wanted to say:

This area of Cowboy was modified because of HTTP/2. Cowboy can no longer give direct socket access and therefore the funs were removed. Instead, sendfile is now a tuple that can be given anywhere a body or body segment is expected (so there can be more than one).

form input tag's name attribute should handle all of CDATA

A form input tag's name attribute should be able to contain any CDATA characters. At least according to http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

Currently quite a limited (albeit the vastly most common) set of characters are supported by https://github.com/nitrogen/simple_bridge/blob/master/src/simple_bridge_request_wrapper.erl#L97 but it breaks when you want to parse an array of things like Chicago Boss model IDs like the following because of the hyphen

<input type... name="items[word-3]" />
<input type... name="items[word-5]" />

Of course there are many workarounds and I'm not even providing a patch, but I thought I'd log the issue until I can provide a patch ans see if there's any interest in such a fix anyway.

"undefined" instead of undefined result when param not found in request

this code

find_param(Param, Default, ParamList) when is_binary(Param) ->
    case lists:keyfind(Param, 1, ParamList) of
        {_, Val} -> Val;
        false -> Default
    end;
find_param(Param, Default, ParamList) when is_atom(Param); is_list(Param) ->
    Param1 = simple_bridge_util:to_binary(Param),
    simple_bridge_util:to_list(find_param(Param1, Default, ParamList)).

makes simple_bridge return "undefined" (list, not atom) for not found params when the key is a list or atom.

yaws deps

Hi Jesse,

Just FYI for erlang 18 we need yaws 2.0 I don't know the exact changes required. The one would be to update simple_bridge/rebar_deps/yaws.deps but not getting it to compile/make.

==> yaws (compile)
yaws.erl:13: can't find include file "yaws_appdeps.hrl"
yaws.erl:221: undefined macro 'YAWS_APPDEPS'
yaws.erl:175: function start_app_deps/0 undefined
yaws.erl:195: function start_app_deps/0 undefined

Incorrect processing of incorrect multipart/form-data requests

simple_bridge hangs when processing incorrectly passed muiltipart/form-data POST body.

How to reproduce:

  1. start using standard make run_inets
  2. execute command curl -X POST -H 'Content-Type: multipart/form-data; boundary=12345' --data-binary "@test-data-bad" "http://localhost:8000/"

Expected result: Error 4xx or 5xx.

Actual result: request never ends (or stop after some timeout).

On large amount of such requests code consumes all CPU resources very quickly.

I've attached test data and sample code in test.sh simple_bridge_post_form.tar.gz

In "bad" payload I use \n instead of \r\n.

As a dirty workaround I use this code in simple_bridge_multipart:

--- a/simple_bridge/src/simple_bridge_multipart.erl
+++ b/simple_bridge/src/simple_bridge_multipart.erl
@@ -230,6 +230,13 @@ get_next_line(Data, Acc, Part, State) when Data == undefined orelse Data == <<>>
 
 read_chunk(State = #state { req=Req, length=Length, bytes_read=BytesRead }) ->
     BytesToRead = lists:min([Length - BytesRead, ?CHUNKSIZE]),
+    if
+        BytesToRead==0 ->
+            error_logger:error_msg("LineEnding failed, state: ~p~n", [State]),
+            erlang:throw({unexpected, line_end, 0});
+        true ->
+            ok
+    end,
     Data = sbw:recv_from_socket(BytesToRead, ?IDLE_TIMEOUT, Req),
     NewBytesRead = BytesRead + size(Data),
     ok=crash_if_too_big(NewBytesRead, State),

Incorrect processing of post requests with abnormal content type

It seems simple bridge tries to parse the body as "application/x-www-urlencoded" when ever a request is not multipart. There are plenty of content-types and use cases where this is not valid.
At least in the case of cowboy this behaviour leads to a crash.
I stumbled about it while building a rest api, that accepts "application/my-app-binary" without urlencoding the content.

Cowboy crash

Here I am again, I got this error with cowboy. Each time a page is loaded, I get 8 error blocks like this:

=ERROR REPORT==== 30-Oct-2014::10:20:49 ===
Error in process <0.3716.0> on node '[email protected]' with exit value: {function_clause,[{cowboy_http,quoted_string,[<<10 bytes>>,#Fun<cowboy_http.19.79668630>],[{file,"src/cowboy_http.erl"},{line,670}]},{cowboy_http,nonempty_list,2,[{file,"src/cowboy_http.erl"},{line,49}]},{cowboy_req,parse_header,4,[{file,"src/cowboy_req.erl"},{line...

=ERROR REPORT==== 30-Oct-2014::10:20:49 ===
Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.3716.0> exit with reason: {function_clause,[{cowboy_http,quoted_string,[<<"jKfJpi1707">>,#Fun<cowboy_http.19.79668630>],[{file,"src/cowboy_http.erl"},{line,670}]},{cowboy_http,nonempty_list,2,[{file,"src/cowboy_http.erl"},{line,49}]},{cowboy_req,parse_header,4,[{file,"src/cowboy_req.erl"},{line,412}]},{cowboy_rest,if_none_match_exists,2,[{file,"src/cowboy_rest.erl"},{line,576}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,435}]}]}

I think is a problem serving js and css files because the page is shown like if these files were not loaded. The strange thing is that in firebug, they appear in the html tab but it seems they are loaded after the html of the page:

Firebug error:
ReferenceError: Nitrogen is not defined

what is impossible because if nitrogen.min.js was loaded, Nitrogen should be defined.

timeout in cowboy_simple_bridge:request_body/1

when I use upload_element in nitrogen, there is a error report for simple_bridge as follow:

=INFO REPORT==== 4-Dec-2014::05:17:35 ===
Upload started.

=ERROR REPORT==== 4-Dec-2014::05:17:36 ===
Error in simple_bridge:make/2 - error - {case_clause,{error,timeout}}
[{cowboy_simple_bridge,request_body,1,
                       [{file,"/home/homeway/erlang/workspace/investors/lib/simple_bridge/src/cowboy_bridge_modules/cowboy_simple_bridge.erl"},
...

I read cowboy document and find this:

 body(Req, Opts) -> {ok, Data, Req2} | {more, Data, Req2}
...
 It will use a timeout of 15s per chunk.

When I deploy local project, and use local browser, the uploaded file with 2M size would uploaded in 15s, all the things worked well.
But when I deploy remote project the error report happened.

Though I change some code in simple_bridge:

%% cowboy_simple_bridge.el
request_body(ReqKey) ->
    {RequestCache, Req} = get_key(ReqKey),
    {Body, NewReq} = case RequestCache#request_cache.body of
        not_loaded ->
            %% We start with 2MB here, as headers and form fields will almost
            %% certainly be in the first 2mb of a request
-           case cowboy_req:body(Req, [{length, 2000000}]) of
+          case cowboy_req:body(Req, [{length, 2000000}, {read_timeout, 120000}]) of
...

It's bug in simple_bridge.
my solution can worked well now, but not pretty.
Perhaps it's a good idea set the timeout in simple_bridge.config.

SSL abstraction with 2.0

This is more of a reminder than anything, but simple_bridge 2.0 should also provide an HTTPS configuration abstractions similar to how it abstracts away other parts of the underlying server configuration into the simple_bridge.config file.

Deep POST params versus numeric index parsing

Deep POST params parsing does not work properly with numeric indices:

> (simple_bridge_request_wrapper:new ([], [], [], [], [], [])):parse_deep_post_params ([{"x[3]","x3:val"}], []).
[{"x",[2,1,0,"x3:val"]}]

...but if we make the index an alphanumeric word, it starts to behave as expected:

> (simple_bridge_request_wrapper:new ([], [], [], [], [], [])):parse_deep_post_params ([{"x[i3]","x3:val"}], []).
[{"x",[{"i3","x3:val"}]}]

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.