[kf-devel] Help needed for porting KF OSGi on Android
demetris at ece.neu.edu
Mon Jan 31 05:02:09 CET 2011
Excellent - thanks very much Gunnar. I will test it out with KF and let you
On 1/30/2011 5:52 AM, Gunnar Ekolin wrote:
> Hi Demetris,
> On Fri, Jan 28, 2011 at 03:18:37PM -0500, Demetris wrote:
>> Hi Gunnar,
>> thanks for the response. I hope all is well.
>>> To which URL is the preflight request sent?
>>> Someone must reply to it, as far as I know the HttpServer does not
>>> know anything about this so you need a servlet (user provided) that
>>> can respond to the request.
>> So what happens is this. I want to use Android devices both as
>> clients of web services
>> (REST and SOAP) and as servers (REST and SOAP). So far I have been using KF
>> on Linux laptops as servers (if you remember we discussed this for a
>> while, Axis2
>> and REST servlets), which has been working very well. Until KF 3.2 comes out
>> I have been working on the client side only. So I use Android's
>> native browser to
>> open an Ajax script that is residing on the phone in iJetty. So I
>> use the URL
>> http://localhost:8080/<path to the script>. The script now has
>> inside calls to the
>> remote KF server which resides at http://<public IP>:8080/<path to
>> REST>. Since
>> the request is not from the same origin (localhost vs public IP) it
>> gets preflighted.
>> So I see HTTP OPTIONS going out to KF but nothing in response. I was
>> under the
>> impression that the server will take care of the response (though a
>> setting) but I was not sure if I could do it at the servlet (user
>> provided) level. If that
>> is the case the I guess I can send the headers below from inside the
>> REST servlet
>> I have in KF ... Do you have any examples in the distribution
>> I can look at? I am assuming these can be sent as a simple text
>> message? Or should
>> I use the HTTP API bundle for them?
>> Access-Control-Allow-Methods: POST,
>> GET, OPTIONS\r\n"+
>> Access-Control-Max-Age: 1728000\r\n"+
>> Content-Length: 0\r\n"+
>> Keep-Alive: timeout=2, max=100\n"+
>> Connection: Keep-Alive\n"+
>> Content-Type: text/plain\r\n"+
>> \t \r\
>> Gunnar once again thanks very much. Your help has been invaluable in
>> the past and I appreciate it
>> very much.
> Just as in php the example on
> https://developer.mozilla.org/En/Server-Side_Access_Control you can
> look at the ORIGIN-header in the HttpServletRequest using the
> Servlet-API and add the required "Access-Control-Allow-Origin" header
> to the response in your servlets running inside the KF HttpServer.
> Similar for the preflight requests using the OPTIONS-http
> I.e., this is something that your application (servlets) must
> handle since there is no special support in the HttpServer for
> configuring these things.
> For those that want to read the full doc of the access-control related
> headers take a look at http://dev.w3.org/2006/waf/access-control/
> Knopflerfish-devel mailing list
> Knopflerfish-devel at knopflerfish.org
More information about the Knopflerfish-devel