How to use http in native client?

73 views
Skip to first unread message

Sailor

unread,
Mar 28, 2014, 4:42:56 AM3/28/14
to native-cli...@googlegroups.com
Hi all,
   I want to use http in native client, but i can't find the method to request web. 
   who know how to do it.

please help me to try it. thank you very much.

Sam Clegg

unread,
Mar 28, 2014, 12:10:20 PM3/28/14
to native-cli...@googlegroups.com
You most likely will want to take a look at URLLoader:
https://developers.google.com/native-client/dev/peppercpp/classpp_1_1_u_r_l_loader

If you are a packaged app and you want more fine grained control you
can also use libcurl from naclports along TCP permissions in your
webstore manifest.

cheers,
sam
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to native-client-di...@googlegroups.com.
> To post to this group, send email to native-cli...@googlegroups.com.
> Visit this group at http://groups.google.com/group/native-client-discuss.
> For more options, visit https://groups.google.com/d/optout.

Sailor

unread,
Mar 30, 2014, 6:05:24 AM3/30/14
to native-cli...@googlegroups.com
Thanks Sam.
1、I wanna know how to use libcurl , and native client support libcurl compeleted?
2、URLLoader occur error when i used, code:
          pp::URLRequestInfo request(this);
  request.SetURL("http://www.google.com");
  request.SetMethod("GET");
  url_request_.SetURL(url);
  request.SetHeaders("application/octet-stream"); 
  int32_t resu = urlLoader.Open(request, cc);
     res value is -1.
please help me answer.

在 2014年3月29日星期六UTC+8上午12时10分20秒,Sam Clegg写道:
You most likely will want to take a look at URLLoader:
https://developers.google.com/native-client/dev/peppercpp/classpp_1_1_u_r_l_loader

If you are a packaged app and you want more fine grained control you
can also use libcurl from naclports along TCP permissions in your
webstore manifest.

cheers,
sam

On Fri, Mar 28, 2014 at 1:42 AM, Sailor <luoch...@gmail.com> wrote:
> Hi all,
>    I want to use http in native client, but i can't find the method to
> request web.
>    who know how to do it.
>
> please help me to try it. thank you very much.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Ben Smith

unread,
Mar 31, 2014, 8:28:21 PM3/31/14
to native-cli...@googlegroups.com
You can see in <ppapi/c/pp_errors.h>, that -1 is PP_OK_COMPLETIONPENDING. This is a valid return result that means that the function will return the result asynchronously in your callback. Your callback will probably return with error, though. This is because of same-origin policy restrictions. Unless the page that is making the request was loaded from the www.google.com origin, your GET request will fail.

For this to work, you need to use Cross-origin Resource Sharing (CORS). This requires support from the server you are communicating with. You also have to call SetAllowCrossOriginRequests on your URLRequestInfo object.

-Ben

Sailor

unread,
Mar 31, 2014, 9:13:09 PM3/31/14
to native-cli...@googlegroups.com
thanks Ben.

Can you help me check the code?

code:
pp::URLRequestInfo request(this);
request.SetAllowCredentials(true);
request.SetAllowCrossOriginRequests(true);
request.SetURL("http://www.google.com.hk");
request.SetMethod("GET");
int32_t resu = urlLoader.Open(request, cc);

The resu is -7 or -11 when application run. I don't know urlloader why so complicated.

在 2014年4月1日星期二UTC+8上午8时28分21秒,Ben Smith写道:
Reply all
Reply to author
Forward
0 new messages