Всем доброго дня суток! У меня проблема с обычным HTTP запросом Код | Socket socket = new Socket("proxy.nsu.ru",8888); OutputStream out = socket.getOutputStream(); InputStream in = socket.getInputStream(); String header = "GET http://www.live-football.cn/ HTTP/1.1\n"; header += "Host: www.live-football.cn\n"; header += "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13\n"; header += "Accept: text/html,application/xhtml+xml,application/xml;q=0.8\n"; header += "Accept-Language: ru,en-us;q=0.7,en;q=0.3\n"; header += "Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7\n"; header += "Keep-Alive: 300\n"; header += "Proxy-Connection: keep-alive\n"; header += "Cookie=__utma: 52245940.610481447.1248987241.1250712238.1250714630.4; __utmz=52245940.1248987241.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); _csuid=491dd24d152bc787; 2cd1ffaf66e67bff316e380fac9ae392=5f564a69e57edb29a78858af358caf0e; __utmc=52245940; __utmb=52245940\n"; header += "\n"; out.write(header.getBytes()); out.flush(); byte[] buffer = new byte[1024*1024]; int count = 0; while((count = in.read(buffer)) != -1){ System.out.println(new String(buffer,0,count)); }
|
ответ получаю Код | Connect Success HTTP/1.0 200 OK Date: Wed, 19 Aug 2009 21:34:22 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.6 Set-Cookie: 2cd1ffaf66e67bff316e380fac9ae392=0dc14289ac3eed795628c35449bf57f0; path=/ P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM" ETag: 6666cd76f96956469e7be39d750cc7d9 Expires: Mon, 1 Jan 2001 00:00:00 GMT Last-Modified: Wed, 19 Aug 2009 21:34:22 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Type: text/html; charset=UTF-8 X-Cache: MISS from proxy.nsu.ru X-Cache-Lookup: MISS from proxy.nsu.ru:8888 Proxy-Connection: close
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
<head>
<base href="http://www.live-football.cn/" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="robots" content="index, follow" /> <meta name="keywords" content="live football, free live football, football stream, Sopcast, TVants, TVU, EPL, Seria A, BundesLiga, SPL, NBA, MLB, NFL" />
|
А когда сам пытаюсь коннектиться Код | Socket socket = new Socket(InetAddress.getByName("www.live-football.cn").getHostAddress(),80); OutputStream out = socket.getOutputStream(); InputStream in = socket.getInputStream(); String header = "GET http://www.live-football.cn/ HTTP/1.1\n"; ...... same code
|
Получаю Код | Connect Success HTTP/1.1 200 OK Date: Wed, 19 Aug 2009 21:33:33 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.6 Set-Cookie: 2cd1ffaf66e67bff316e380fac9ae392=defd918a552ac47f908d525c379d6d71; path=/ P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM" ETag: f03157e22ed0b211d2396cce3502e408 Expires: Mon, 1 Jan 2001 00:00:00 GMT Last-Modified: Wed, 19 Aug 2009 21:33:33 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Connection: close Content-Type: text/html; charset=UTF-8
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
<head>
<base href="http://www.live-football.cnhttp//www.live-football.cn/" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="robots" content="index, follow" /> <meta name="keywords" content="404,not found" /> <meta name="t itle" content="404 - Page Not Found!" /> <meta name="author" content="Administrator" /> <meta name="description" content="404 not found page" /> <meta name="generator" content="Joomla! 1.5 - Open Source Content Management" /> <title>404 - Page Not Found! - Free Live Football</title>
|
Обратите внимание на ТЭГ : это первый случай когда через прокси <base href="http://www.live-football.cn/" />а вот это второй случай когда через сокет... <base href="http://www.live-football.cnhttp//www.live-football.cn/" />не могу понять в чем проблема... почему сервер два раза записыват свой урл в <base/>... Причем остальные сайты работают безукоризненно.
|