Question about parametrized modules

Filipe David Manana fdmanana@REDACTED
Sun Aug 8 15:47:27 CEST 2010


I have a function_clause error when calling some functions of a parametrized
module which use one of the module parameters.
The module in question (from mochiweb) is like:

-module(mochiweb_request, [Socket, Method, RawPath, Version, Headers]).
-export([get/1]).

% ...

get(socket) ->
   Socket;
get(scheme) ->
   case mochiweb_socket:type(Socket) of
       plain ->
           http;
       ssl ->
           https
   end;
get(method) ->
   Method;
get(raw_path) ->
   RawPath;
get(version) ->
   Version;
get(headers) ->
   Headers;

Then, from another module, which has an instance of that parametrized module
(mochiweb_request) I have:

1) a call like MochiReq:get(socket)  - this one succeeds

2) a call like MochiReq:get(scheme) - it fails with the stack trace bellow:

           {error,function_clause,
               [{mochiweb_request,get,
                    [scheme,
                     {mochiweb_request,#Port<0.2224>,'GET',"/_utils",
                         {1,1},
                         {10,
                          {"host",
                           {'Host',"localhost:5984"},
                           {"accept",
                            {'Accept',

"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},
                            nil,
                            {"accept-language",
                             {'Accept-Language',"en-us,en;q=0.5"},
                             {"accept-encoding",
                              {'Accept-Encoding',"gzip,deflate"},
                              {"accept-charset",
                               {'Accept-Charset',
                                   "ISO-8859-1,utf-8;q=0.7,*;q=0.7"},
                               nil,nil},
                              nil},
                             {"connection",
                              {'Connection',"keep-alive"},
                              {"cache-control",
                               {'Cache-Control',"max-age=0"},
                               nil,nil},
                              {"cookie",
                               {'Cookie',
                                   "5984_recent=testdb;
AuthSession=ZmRtYW5hbmE6NEM1RUEyMkE60TPWV73IdXUYV68s4MUDLuI4P6o"},
                               nil,nil}}}},
                           {"user-agent",
                            {'User-Agent',
                                "Mozilla/5.0 (Macintosh; U; Intel Mac OS X
10.6; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"},
                            {"keep-alive",{'Keep-Alive',"115"},nil,nil},
                            nil}}}}]},

I suspect there's something missing in mochiweb_request:get(scheme) when
referencing the module parameter Socket.
Does anyone have an idea an can explain me what's wrong?

cheers

-- 
Filipe David Manana,
fdmanana@REDACTED

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."


More information about the erlang-questions mailing list