[python] sockety - problem s HTTP spojenim

Leos Pol leos na radiante-corp.com
Čtvrtek Listopad 15 16:21:15 CET 2007


Zdravim,

v podstate vsechno dobre, jen ze socketu pak nactete jen 100B, takze 
radek recv bych treba prepsal na tohle:

    buf = ''
    read = clisock.recv(4096)
    while read:
        buf += read
        read = clisock.recv(4096)
    print buf


Leo

Tomy novella wrote:
> ahoj,
> ucim sa zaklady prace so socketmi, tak som si napisal takyto skriptik:
>
> import socket
> clisock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> clisock.connect(('ww1.chatq.sk', 80))
> clisock.send('GET /index.php HTTP/1.0\nHost: ww1.chatq.sk\n\n')
> print clisock.recv(100)
> clisock.close()
> print "koniec"
>
> problemom vsak je, ze ked ho spustim, tak mi vrati nieco taketo:
>
> HTTP/1.1 200 OK
> Date: Thu, 15 Nov 2007 15:04:15 GMT
> Server: Apache
> X-Powered-By: PHP/4.4.8_pre200
> koniec
>
> a ja pritom chcem, aby mi vratilo aj cely HTML kod, ktory by mal
> apache vraciat...
> preco ho nevracia a vracia mi spat len par hlaviciek?
>
> aa ako ceresnicka by ma zaujimalo, ze preco ked to pytam cez HTTP
> verziu 1.0, tak mi to vracia cez HTTP 1.1 :)
>
> diky :)
>
>   


-- 
----
Leos Pol
Team Leader
Radiante Corp.

If it can be imagined,
we can implement it



Další informace o konferenci Python