adrnsoh / codenameone

Automatically exported from code.google.com/p/codenameone
0 stars 0 forks source link

"411 Length Required" dialog when using Network Manager #99

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Implement a POST request to Google reverse geocoder API

What is the expected output? What do you see instead?
A dialog pops up with the server response "411 Length Required", and adding the 
Content-Length request header does not resolve it.  Converting to GET request 
does, but not sure what happens when a service is called that requires a 
payload.

What version of the product are you using? On what operating system?
0.1 build 20120312 on Ubuntu 11.10.

Please provide any additional information below.

The following is my posting to the discussion group, Shai asked me to post an 
issue to track it:

Just a heads up, had a strange case when trying to use the Google APIs, I was 
getting a dialog popup up that said "411 Length Required". and calling 
ConnectionRequest::addRequestHeader("Content-Length", "0") did not resolve it.

In this case, what I needed to do was cal ConnectionRequest::setPost(false) and 
move all of my ConnectionRequest::addArgument() calls to hardcoded arguments in 
the URL,
ie.

        String url = "https://maps.googleapis.com/maps/api/geocode/json";
        request.setUrl(url);
        request.addArgument("sensor", "true");
        request.addArgument("latlng", geoLocation.getLatitude() + "," + geoLocation.getLongtitude());

became:

        String url = "https://maps.googleapis.com/maps/api/geocode/json?sensor=true&latlng="
                + geoLocation.getLatitude() + "," + geoLocation.getLongtitude();
       request.setPost(false);
       request.setUrl(url);

I'm not sure how to handle that server error if your actually need to post data 
to a google service, maybe it doesn't get thrown if you actually have a payload.

Original issue reported on code.google.com by 1815...@coolman.ca on 15 Mar 2012 at 7:30