Send HTTP request manually via socket

后端 未结 4 725
[愿得一人]
[愿得一人] 2020-11-28 05:15

When I send a normal HTTP request via a socket, the server does not respond with an OK response. I copied the HTTP header from Firefox. Here is the code:

Soc         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 05:56

    The correct fix which really works and it is cross platform:

        pw.print("GET / HTTP/1.1\r\n");
        pw.print("Host: stackoverflow.com\r\n\r\n");
    

提交回复
热议问题