Ryan Zezeski | 2 Jul 16:42 2010
Picon

PUT large files

Hi, I'm new to both Erlang and Yaws so please be gentle on me if I'm about to ask a stupid question.


I wrote an appmod in Yaws that accepts large CSV files, creates a document in CouchDB, and then adds the CSV as a standalone attachment.  The size of the CSV I'm using to test is 163M (3.4M+ rows).  Here is the CURL command I run:

curl -v -XPUT -H 'Content-Type: text/csv' '<url here>' --data-binary <at> data/data.csv

This will fail immediately, and with trace on I see an enomem error.  However, if I change to chunked transfer encoding via -H 'Transfer-Encoding: chunked' then it works just fine.  Looking through the source code it looks like body_method/3 is responsible for pulling the data from the socket.  If chunked it eventually does the following:

    yaws:setopts(CliSock, [binary, {packet, line}],SSL),
    N = yaws:get_chunk_num(CliSock,SSL),
    yaws:setopts(CliSock, [binary, {packet, raw}],SSL),

My guess is this has something to do with it working.  Although, I don't get why it sets packet to line, and then to raw.  Why not just raw?

My question, then, is there a way this can work without requiring the transfer encoding to be set to chunked?

-Ryan
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@...
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Steve Vinoski | 2 Jul 19:34 2010
Picon

Re: PUT large files

On Fri, Jul 2, 2010 at 10:42 AM, Ryan Zezeski <rzezeski@...> wrote:
> Hi, I'm new to both Erlang and Yaws so please be gentle on me if I'm about
> to ask a stupid question.
> I wrote an appmod in Yaws that accepts large CSV files, creates a document
> in CouchDB, and then adds the CSV as a standalone attachment.  The size of
> the CSV I'm using to test is 163M (3.4M+ rows).  Here is the CURL command I
> run:
> curl -v -XPUT -H 'Content-Type: text/csv' '<url here>' --data-binary
>  <at> data/data.csv
> This will fail immediately, and with trace on I see an enomem error.
>  However, if I change to chunked transfer encoding via -H
> 'Transfer-Encoding: chunked' then it works just fine.  Looking through the
> source code it looks like body_method/3 is responsible for pulling the data
> from the socket.  If chunked it eventually does the following:
>     yaws:setopts(CliSock, [binary, {packet, line}],SSL),
>     N = yaws:get_chunk_num(CliSock,SSL),
>     yaws:setopts(CliSock, [binary, {packet, raw}],SSL),
> My guess is this has something to do with it working.  Although, I don't get
> why it sets packet to line, and then to raw.  Why not just raw?
> My question, then, is there a way this can work without requiring the
> transfer encoding to be set to chunked?

Unfortunately this isn't well documented from what I can see.

In your appmod, check the Arg clidata field. If it's a 2-tuple where
the first element is the atom partial, then you got only part of the
your PUT or POST data, and you have to tell Yaws to get more for you.
The size of the partial data is controlled by the partial_post_size
server configuration variable, which defaults to 10240. You can set it
to the atom nolimit to allow unlimited uploads, but I'd be worried
about that enomem in that case.

For example:

out(Arg) ->
    case Arg#arg.clidata of
        {partial, Data} ->
            %% write Data to CouchDB or whatever...
            %% then tell Yaws you want more data
            {get_more, Cont, State};
        Data ->
            %% no more partial data, must be the end
            {status, 204}
    end.

Here, when we get partial data, we return the get_more atom to Yaws to
tell it to read more and call us back. The Cont and State variables
are entirely up to you, set them to whatever you like. When Yaws calls
you back with the next chunk, Arg#arg.cont and Arg#arg.state will be
set to whatever Cont and State you returned last time, respectively.
They allow you to keep state across the calls. If you don't need them,
just set them to the atom undefined.

The second case clause handles the end of the data. I have it return a
204 No Content here in the example, but obviously you can return
whatever you like to indicate success or failure for the operation.

--steve

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Branko Vukelic | 5 Jul 11:58 2010
Picon

Write rendered EHTML to file

Hi,

Is there a way to write rendered EHTML to a file instead of returning it?

What I'm trying to do is to make a appmod for generating static HTML
pages based on user input that will be placed in a directory that is
served as a regular static site.

Thanks,

-- 
Branko Vukelić

bg.branko <at> gmail.com
studio <at> brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Claes Wikstrom | 5 Jul 12:19 2010

Re: Write rendered EHTML to file

On 07/05/2010 11:58 AM, Branko Vukelic wrote:
> Hi,
>
> Is there a way to write rendered EHTML to a file instead of returning it?
>
> What I'm trying to do is to make a appmod for generating static HTML
> pages based on user input that will be placed in a directory that is
> served as a regular static site.
>

Almost,

When the yaws server receives your {ehtml, E} data, it calls
yaws_api:ehtml_expand(E) - you can do the same from your code
before returning - if you then don't want the expand to occur
twice, you can do:

{ok,Html} = yaws_api:expand(E),
file:write(FileFd, Html),
{html, Html}

in your code.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Branko Vukelic | 5 Jul 12:34 2010
Picon

Re: Write rendered EHTML to file

On Mon, Jul 5, 2010 at 12:19 PM, Claes Wikstrom <klacke <at> tail-f.com> wrote:
> Almost,
>
> When the yaws server receives your {ehtml, E} data, it calls
> yaws_api:ehtml_expand(E) - you can do the same from your code
> before returning - if you then don't want the expand to occur
> twice, you can do:
>
> {ok,Html} = yaws_api:expand(E),
> file:write(FileFd, Html),
> {html, Html}

Thanks Claes, Rapsey. This was very helpful!

-- 
Branko Vukelić

bg.branko <at> gmail.com
studio <at> brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
tech | 7 Jul 13:44 2010
Picon

Yaws, SSL Certificates & IE8

Good morning,

has anyone here run into the following when using certain versions of IE 
(using yaws 1.88 and otp 5.8 (R14A)).

=ERROR REPORT==== 6-Jul-2010::12:25:54 ===
SSL: decipher_error: ./ssl_record.erl:680:Fatal error: bad record mac

=ERROR REPORT==== 6-Jul-2010::12:25:54 ===
Unhandled reply fr. do_recv() {error,"bad record mac"}

Now for the intriguing part - Firefox, Opera, Safari - connects to the server 
with no issues.

Any suggestions are welcome :)

-------------------------------------------------------

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Claes Wikstrom | 7 Jul 14:46 2010

Re: Yaws, SSL Certificates & IE8

On 07/07/2010 01:44 PM, tech@... wrote:
> Good morning,
>
> has anyone here run into the following when using certain versions of IE
> (using yaws 1.88 and otp 5.8 (R14A)).
>
> =ERROR REPORT==== 6-Jul-2010::12:25:54 ===
> SSL: decipher_error: ./ssl_record.erl:680:Fatal error: bad record mac
>
> =ERROR REPORT==== 6-Jul-2010::12:25:54 ===
> Unhandled reply fr. do_recv() {error,"bad record mac"}
>
> Now for the intriguing part - Firefox, Opera, Safari - connects to the server
> with no issues.
>
> Any suggestions are welcome :)

Never seen - it could be that openssl works around this. I know that 
there are quite a few "work with bad ssl client" code portions in the
openssl code.

You'll either have to:

- ignore the error and not work with those browsers
- Debug the erlang ssl code and handle this broken client someway.
- Use the old ssl implementation

Pick one, :-(

/klacke

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Alexandre Biancalana | 12 Jul 17:11 2010
Picon

mod_status like

Hi list,

 Is there any module or something to yaws that give information like
apache mod_status ?

Regards,
Alexandre

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Steve Vinoski | 12 Jul 19:27 2010
Picon

Re: mod_status like

On Mon, Jul 12, 2010 at 11:11 AM, Alexandre Biancalana
<biancalana@...> wrote:
> Hi list,
>
>  Is there any module or something to yaws that give information like
> apache mod_status ?

There's a configuration setting for virtual servers named "statistics"
that you can set to true to gather statistics for that server. You
then run "yaws --stats" from the command line to see the stats. See
also the file munin/README.munin in the source code to see how to make
use of the data.

--steve

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Alexandre Biancalana | 12 Jul 20:52 2010
Picon

Re: mod_status like

On Mon, Jul 12, 2010 at 2:27 PM, Steve Vinoski <vinoski@...> wrote:
> On Mon, Jul 12, 2010 at 11:11 AM, Alexandre Biancalana
> <biancalana@...> wrote:
>> Hi list,
>>
>>  Is there any module or something to yaws that give information like
>> apache mod_status ?
>
> There's a configuration setting for virtual servers named "statistics"
> that you can set to true to gather statistics for that server. You
> then run "yaws --stats" from the command line to see the stats. See
> also the file munin/README.munin in the source code to see how to make
> use of the data.

Hi Steve,

I'm using embeded mode, the "statistics" is set to true.

But I'm having problems

# yaws --stats
You failed to read the ctlfile /root/.yaws/yaws/default/CTL
error was: <enoent>
specify by <-I id> which yaws system you want  to control

# yaws -I 1 --stats
You failed to read the ctlfile /root/.yaws/yaws/1/CTL
error was: <enoent>
specify by <-I id> which yaws system you want  to control

Any hint ?

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first

Gmane