I prefer using the yaws_api:embedded_start_conf/1,2,3,4 functions where possible because they encapsulate all the details of setting the yaws startup environment properly, setting the global and server confs properly, etc. They also allow you to pass property lists for the confs rather than requiring the use of the conf records.

Some parts are still unfortunately tricky to configure this way, though, such the flags setting, which is basically a bitfield set via the macros Christopher mentioned, and also the setting of sub-fields i.e. fields that are in records that themselves are then set as fields in the top-level confs. Since this embedded config problem seems to be coming up more frequently lately, I might have to see if I can make some changes in this area to make it easier.

But to address your compression problem, I suggest checking the Content-Encoding header that's being returned from yaws when you call your curl command. This should tell you whether compression is occurring. I'm not sure but since you're using the --compressed option, curl might be hiding the compression from you. An alternative might be to use netcat (the nc command on Linux or OS X) to send a request to yaws, as that way you can more easily see raw HTTP headers and responses. You can also have a look at test/t5/app_test.erl in the yaws source tree, since that includes tests for compression.

--steve



On Thu, Apr 17, 2014 at 1:47 AM, Marutha <maruthavanan.s@gmail.com> wrote:
HI,

Thanks, I have tried setting the deflate flag using the ?sc_set_deflate macro like below. But still I could not see the output compressed from yaws, are there any dependencies or packages to be installed? How should I verify this, as of now I am using curl?

    application:start(yaws),
    DeflateOptions = #deflate{mime_types = all,
                              compression_level = best_compression},
    yaws:mkdir(yaws:id_dir(Id)),
    DefaultGC = yaws_config:make_default_gconf(Debug, Id),
    GC = DefaultGC#gconf{logdir="./log/", log_wrap_size = 100000000},
    SC = #sconf{port = Port,
                %% servername = "ubuntu01",
                listen = {0,0,0,0},
                docroot = "./www/",
                appmods = [{"/", yaws_callback, [["style"]]}],
                deflate_options = DeflateOptions
               },
    UpdatedSC = ?sc_set_deflate(SC, true),
    _Result = yaws_api:setconf(GC, [[UpdatedSC]]),

and curl command that I am using to test is 

curl -I 'http://localhost/' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Cookie: m=3247:t|34e2:|ca3:t' -H 'Connection: keep-alive' --compressed

Thanks,

Marutha




On Wed, Apr 16, 2014 at 6:56 PM, Christopher Faulet <christopher.faulet@capflam.org> wrote:
On 16/04/2014 14:36, Marutha wrote:
> Hi,
>
> I am running yaws in embedded mode and I would like to enable the
> deflate option so I created sconf like below,
>
> DeflateOptions*=**#**deflate*{mime_types*=*all,
>
>                             compression_level*=*best_compression},
>
> SC*=**#sconf*{port*=*Port,
>
>                    listen*=*{0,0,0,0},
>
>                    docroot*=*"./www/",
>
>                    appmods*=*[{"/", yaws_callback, [["style"]]}],
>
>                    deflate_options*=*DeflateOptions
>
>                   },
>
> I tried the default record of deflate{} too. but I could not find the
> output to be compressed when started yaws in embedded mode. Is there
> something I have missed out ? I am starting yaws using
> application:start(yaws) and then later yaws_api:set_conf function. Could
> this be a problem? or yaws should be started after yaws_api:set_conf
> function is called?
>

Hi,

#sconf.deflate_options si used to define the behavior of Yaws when the
deflate option is enabled. To enable it, you need to update #sconf.flags
field by calling the macro ?sc_set_deflate.

--
Christopher


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list