Re: [chicagoboss] inets:httpc into my lib.

119 views
Skip to first unread message

Bip Thelin

unread,
Nov 27, 2012, 6:38:51 AM11/27/12
to chica...@googlegroups.com
On 27 nov 2012, at 11:45, guyvernk <gl...@guyvernk.com> wrote:

4. Get error.

{noproc,
    {gen_server,call,
        [httpc_manager,
         {request,
             {request,undefined,<0.149.0>,0,http,
                 {"oauth.vk.com",80},
                 "/authorize",
                 "?client_id=2843514&scope=999999&redirect_uri=http://oauth.vk.com/blank.html&display=touch&response_type=token",
                 get,
                 {http_request_h,undefined,"keep-alive",undefined,undefined,
                     undefined,undefined,undefined,undefined,undefined,
                     undefined,undefined,undefined,undefined,undefined,
                     undefined,undefined,"oauth.vk.com",undefined,undefined,
                     undefined,undefined,undefined,undefined,undefined,
                     undefined,undefined,[],undefined,undefined,undefined,
                     undefined,"0",undefined,undefined,undefined,undefined,
                     undefined,undefined,[]},
                 {[],[]},
                 {http_options,"HTTP/1.1",infinity,true,
                     {essl,[]},
                     undefined,false,infinity,false},
                 "http://oauth.vk.com/authorize?client_id=2843514&scope=999999&redirect_uri=http://oauth.vk.com/blank.html&display=touch&response_type=token",
                 [],none,[],1354012968812,undefined,undefined,false}},
         infinity]}}


Help please. What i must to do to get response?

You need to start inets. application:start(inets). Note that if you don't do a proper release(erlang release) of your cb-app your .app-file is basically ignored.

--
Bip Thelin
 
KIVRA | Lugnets Allé 1 | 120 30 Stockholm
Tel 08-533 335 37 | Mob 0735-18 18 90
www.kivra.com


Bip Thelin

unread,
Nov 27, 2012, 6:56:58 AM11/27/12
to guyvernk, chica...@googlegroups.com
On 27 nov 2012, at 12:45, guyvernk <gl...@guyvernk.com> wrote:

Thank you for response.
But i test in init-dev console.

(test@main)1> application:start("ssl").
{error,{bad_application,"ssl"}}
(test@main)2> application:start("inets").
{error,{bad_application,"inets"}}
(test@main)3>

ssl and inets are atoms, not strings. And you need to start crypto and public_key before ssl:

1> application:start(inets).
ok
2> application:start(crypto).
ok
3> application:start(public_key).
ok
4> application:start(ssl).       
ok

Tim McNamara

unread,
Nov 27, 2012, 1:37:43 PM11/27/12
to chica...@googlegroups.com, b...@kivra.com
There are two ways to approach this.

The more complicated way is by using Chicago Boss init scripts. You can see an example of how to create one on pages 31-32 of the Chicago Boss tutorial. These scripts live in /priv/init. You may want to learn how this works, because then you can start any amount of complex behaviour when CB starts up.

The other is to add ssl and inets to your site_name.app.src file in /src.

But is it good solution?
Start modules every time on call function?

--
 
 

Konstantin Nikiforov

unread,
Nov 27, 2012, 10:18:17 AM11/27/12
to chica...@googlegroups.com
You need to encode hostname using punycode[1] and path with
percent-encoding[2] before making a request.

[1] - https://github.com/superbobry/idna See README
[2] - See mochiweb_util:quote_plus/1 function


В Tue, 27 Nov 2012 06:58:05 -0800 (PST)
guyvernk <gl...@guyvernk.com> пишет:

> I'm so sorry, but addinoinal question.
> How use unicode string in request?
> If i use unicode in Url - error happend.
>
> crasher:
> > initial call: httpc_handler:init/1
> > pid: <0.172.0>
> > registered_name: []
> > exception error: bad argument
> > in function iolist_to_binary/1
> > called as iolist_to_binary(["GET"," ",
> > [47,109,101,116,104,111,100,47,97,117,
> >
> > 100,105,111,46,115,101,97,114,99,104,63,
> >
> > 1083,1086,1083,38,97,99,99,101,115,115,
> >
> > 95,116,111,107,101,110,61,101,50,102,50,
> >
> > 98,55,53,100,101,50,101,101,52,55,51,48,
> >
> > 101,50,101,101,52,55,51,48,97,51,101,50,
> >
> > 100,102,102,55,54,57,101,101,50,101,102,
> >
> > 101,50,101,49,48,53,48,101,98,50,53,97,
> >
> > 101,50,49,51,50,98,98,55,98,100,56,57,
> > 101,99,55,56,53,101,99,50],
> > " ","HTTP/1.1","\r\n",
> > "te: \r\nhost:
> > api.vk.com\r\nconnection: keep-alive\r\n",
> > "\r\n",[]])
> >
> >
>

Konstantin Nikiforov

unread,
Nov 27, 2012, 10:29:29 AM11/27/12
to chica...@googlegroups.com
> Start modules every time on call function?

See startup-scripts in $YOUR_PROJECT/priv/init/*
signature.asc
Reply all
Reply to author
Forward
0 new messages