problems uploading large files

14 views
Skip to first unread message

etnt

unread,
May 21, 2010, 3:01:09 PM5/21/10
to Nitrogen Web Framework for Erlang
Hi,

I'm having problems when uploading e.g. a large image.
Both Inets and Mochiweb is crashing somewhere...

I did some quick tracing with redbug:


18:11:59 <{mochiweb_socket_server,acceptor_loop,1}>
{mochiweb_http,headers,
[#Port<0.4910>,
{'POST',
{abs_path,"/
new"},
{1,1}},
[{'Cache-
Control',
"no-cache"},
{'Pragma',"no-
cache"},
{'Cookie',

"newcookie=k9u98oNoAmgDZAAFc3RhdGVtAAAAEKiOSstiBers7s4dZRcVCNZkAAl1bmRlZmluZWRoA2IAAAT6YgAG_j1iAABMUw"},
{'Content-
Length',
"1537"},
{'Referer',
"http://
localhost:8283/new"},
{"X-Requested-
With",

"XMLHttpRequest"},
{'Content-
Type',
"application/x-
www-form-urlencoded; charset=UTF-8"},
{'Connection',
"keep-alive"},
{'Keep-
Alive',"300"},
{'Accept-
Charset',

"ISO-8859-1,utf-8;q=0.7,*;q=0.7"},
{'Accept-
Encoding',

"gzip,deflate"},
{'Accept-
Language',
"en-
us,en;q=0.5"},
{'Accept',
"text/plain, */
*"},
{'User-Agent',
"Mozilla/5.0
(X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100401 Ubuntu/9.10
(karmic) Firefox/3.5.9"},
{'Host',
"localhost:
8283"}],

#Fun<redhot2_inets.0.42989643>,
15]}
(redhot2@myggan)2>
=ERROR REPORT==== 21-May-2010::18:11:59 ===
Error in simple_bridge_request:make/2 - throw - {unexpected,
{error,exit,normal}}
[{simple_bridge_request,make_nocatch,2},
{simple_bridge_request,make,2},
{redhot2_inets,do_mochiweb,1},
{mochiweb_http,headers,5},

{proc_lib,init_p_do_apply,3}]
=ERROR REPORT==== 21-May-2010::18:11:59 ===
{mochiweb_socket_server,235,{child_error,{unexpected,
{error,exit,normal}}}}
quitting: timeout
(redhot2@myggan)2> redbug:start(15000,1000, [{mochiweb_http,headers,
[return]}]).
ok

Hard to say anything from this, so I wonder if someone else has seen
similar problems?

--Tobbe

--
You received this message because you are subscribed to the Google Groups "Nitrogen Web Framework for Erlang" group.
To post to this group, send email to nitro...@googlegroups.com.
To unsubscribe from this group, send email to nitrogenweb...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nitrogenweb?hl=en.

etnt

unread,
May 21, 2010, 6:19:59 PM5/21/10
to Nitrogen Web Framework for Erlang
Ok, I got the upload to work together with Yaws.
But, I had to make the following patch:

diff --git a/apps/simple_bridge/src/yaws_bridge_modules/
yaws_response_bridge.erl b/apps/simple_bridg
index 1ec112b..ce7ce1d 100644
--- a/apps/simple_bridge/src/yaws_bridge_modules/
yaws_response_bridge.erl
+++ b/apps/simple_bridge/src/yaws_bridge_modules/
yaws_response_bridge.erl
@@ -21,10 +21,10 @@ build_response(_Arg, Res) ->

% Get the content type...
ContentType = coalesce([
- proplists:get_value(content_type,
Res#response.headers),
- proplists:get_value("content-type",
Res#response.headers),
- proplists:get_value("Content-Type",
Res#response.headers),
- proplists:get_value("CONTENT-TYPE",
Res#response.headers),
+ kvl3(content_type, Res#response.headers),
+ kvl3("content-type", Res#response.headers),
+ kvl3("Content-Type", Res#response.headers),
+ kvl3("CONTENT-TYPE", Res#response.headers),
"text/html"
]),

@@ -48,6 +48,12 @@ build_response(_Arg, Res) ->
{page, {Options, Path}}
end.

+kvl3(Key,L) ->
+ case lists:keysearch(Key,2,L) of
+ {value, {_,_,Val}} -> Val;
+ _ -> undefined
+ end.
+
coalesce([]) -> undefined;
coalesce([undefined|T]) -> coalesce(T);
coalesce([H|_T]) -> H.


--Tobbe

On May 21, 8:01 pm, etnt <torbjorn.tornkv...@gmail.com> wrote:
> Hi,
>
> I'm having problems when uploading e.g. a large image.
> Both Inets and Mochiweb is crashing somewhere...
>
> I did some quick tracing with redbug:
>
> 18:11:59 <{mochiweb_socket_server,acceptor_loop,1}>
> {mochiweb_http,headers,
>                                                      [#Port<0.4910>,
>                                                       {'POST',
>                                                        {abs_path,"/
> new"},
>                                                        {1,1}},
>                                                       [{'Cache-
> Control',
>                                                         "no-cache"},
>                                                        {'Pragma',"no-
> cache"},
>                                                        {'Cookie',
>
> "newcookie=k9u98oNoAmgDZAAFc3RhdGVtAAAAEKiOSstiBers7s4dZRcVCNZkAAl1bmRlZmlu ZWRoA2IAAAT6YgAG_j1iAABMUw"},

Steve Davis

unread,
May 21, 2010, 8:35:33 PM5/21/10
to Nitrogen Web Framework for Erlang
Hi Tobbe,

IIRC mochiweb has a hard coded maximum request size somewhere....

/s

On May 21, 5:19 pm, etnt <torbjorn.tornkv...@gmail.com> wrote:
> Ok, I got the upload to work together with Yaws.
> But, I had to make the following patch:

etnt

unread,
May 23, 2010, 4:37:33 AM5/23/10
to Nitrogen Web Framework for Erlang
Sorry, but there is still some problems.
With Yaws and FF as a client it works fine but
with Chrome/Chromium it seems like the reply from
element_upload:event isn't taken care of properly by the client.

I added the following line to
element_upload:event({upload_finished.....

% Set the response...
wf_context:data([
"<html><body><script>",
- "var Nitrogen = window.parent.Nitrogen;",
+ "var Nitrogen = window.parent.Nitrogen;alert('tralala');",
Postback,
"</script></body></html>"
]);

with FF, the alert box pops up, with Chromium it does not.

Somebody else must have seen this problem when uploading large files
from Chromium ?

--Tobbe
Reply all
Reply to author
Forward
0 new messages