HTTP GET requests - strange results
in
Core Library Questions
•
2 years ago
I'm trying the Networking example and I'm getting strange results. Ultimately I simply want to return a twitter search query which there
searchAPI says you can get with a simple HTTP GET on say
http://search.twitter.com/search.atom?q=Nottingham and indeed you get a nice string of XML in a browser with this URL.
However, I'm getting a strange return on www.processing.org. Running:
- import processing.net.*;
-
- Client c;
- String data;
-
- void setup() {
- size(200, 200);
- background(50);
- fill(200);
- c = new Client(this, "www.processing.org", 80); // Connect to server on port 80
- c.write("GET / HTTP/1.1\r\n"); // Use the HTTP "GET" command to ask for a Web page
- c.write("Host: 82.69.234.94\n\n"); // Be polite and say who we are
- }
-
- void draw() {
- if (c.available() > 0) { // If there's incoming data from the client...
- data = c.readString(); // ...then grab it and print it
- println(data);
- }
- }
Returns
HTTP/1.1 200 OKDate: Fri, 29 Apr 2011 11:10:00 GMTServer: Apache/2.2.14 (Ubuntu)Set-Cookie: cookiecookiecookie=82.69.234.94.1304075400820406; path=/; expires=Tue, 22-Apr-36 11:10:00 GMT; domain=.processing.orgLast-Modified: Sat, 07 Aug 2010 18:10:10 GMTETag: "830c90d-1cd-48d3fb1a9e480"Accept-Ranges: bytesContent-Length: 461Vary: Accept-EncodingContent-Type: text/html
<html>
<!-- why yes, this was written by hand! and yes, it is HTML 2.0. or worse.but the more important question is... why are you reading this? -->
<head> <title>android.processing.org</title> </head>
<body>
<center> <table width="500"> <tr> <td><font face="verdana, sans-serif" size=1>
<h3> Processing for Android </h3>
This page has moved <a href="http://wiki.processing.org/w/Android">to the wiki</a>.
</td> </tr> </table>
</body>
</html>
WHich is not what I was expecting. And when I run
And a whole load more error lines.java.net.UnknownHostException: search.twitter.com/search.atom?q=Nottingham
I'm behind a domestic router which has the external IP 82.69.234.94 and my laptop is on 192.168.2.17 behind that router. I've tried on processing 1.2.1 and dev 0194, same results. Running Ubuntu with java 6...
1