Well, I really hoped I could handle this without asking here, but I can't :( The idea is pretty simple, you have this link http://cetatenie.just.ro/ and the link is important, because it works for others.
You want to perform a HTTP GET on it from GAE - locally for now, that's it!
If I do it in main class, something like this :
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://cetatenie.just.ro/");
HttpResponse response = httpClient.execute(httpGet);
And then parse the response everything is fine, now I do the same (almost) thing in GAE - locally (in Eclipse --> Run As --> Web Application), with the help of the Eclipse GAE plugin.
FetchOptions fetchOptions = FetchOptions.Builder.withDeadline(50000);
HTTPRequest request = new HTTPRequest(new URL("http://cetatenie.just.ro/"), HTTPMethod.GET, fetchOptions);
System.out.println("ULR-->" + request.getURL());
URLFetchService service = URLFetchServiceFactory.getURLFetchService();
HTTPResponse response = service.fetch(request);
System.out.println("RESPONSE_CODE-->" + response.getResponseCode());
String responseAsString = new String(response.getContent());
System.out.println("RESPONSE_AS_STRING-->" + responseAsString);
I always get a Http 500 error code. I know that this indicates on a server problem, but how come it works from my stand-alone application?
Is GAE doing something fishy?
Regards, Eugene.
Damn! This was easy actually - when sending the request I was missing two headers (seems like GAE is like a telnet - not sending any headers unless you specify them). Anyhow here is what I added: