2016-03-21 16 views
1

Bir localhost web sitesini ziyaret etmek için yuva kullanıyorum. aşağıdaBir localhost web sitesini ziyaret etmek için soket kullanma. Hata

HTTP/1.1 408 Request Timeout 
Content-Length: 0 
Content-Type: text/plain 

soket kodu:

import socket 
mysock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) 
mysock.connect(('0.0.0.0',8080)) 

mysock.send('GET http://localhost:8080/hello HTTP/1.0\r\n') 

while True: 
    data = mysock.recv(512) 
    if (len(data)<1): 
     break 
    print data 
mysock.close() 

cevap

1

HTTP istek başlığı iki yenisatırlar bitmelidir aşağıdaki hatayı alın. Yalnızca bir boş satır gönderirseniz, sunucu zaman aşımına kadar bekler.

mysock.send('GET http://localhost:8000/hello HTTP/1.0\r\n\r\n') 
İlgili konular