Your code works for me, more or less.
Because your read loop reads to EOF and HTTP 1.1 by default uses
persistent connections, the server doesn't close the connection after
sending the response and the loop blocks until the server eventually
times out the now idle connection. You need to request Connection:
close or obey the Content-Length response header to know when to stop
reading.
Connection reset is typically sent by overloaded Windows servers, and
the host you're having problems with is running Windows. It worked
when I tried it.
However instead of implementing this myself I'd use URLConnection, as
others have suggested.
/gordon
一般情况下 是window下面发送请求会出现这个问题
Because your read loop reads to EOF and HTTP 1.1 by default uses
persistent connections, the server doesn't close the connection after
sending the response and the loop blocks until the server eventually
times out the now idle connection. You need to request Connection:
close or obey the Content-Length response header to know when to stop
reading.
Connection reset is typically sent by overloaded Windows servers, and
the host you're having problems with is running Windows. It worked
when I tried it.
However instead of implementing this myself I'd use URLConnection, as
others have suggested.
/gordon
一般情况下 是window下面发送请求会出现这个问题