我正在使用以下代码发送简单的 HTTP 请求:
try
{
Socket s = new Socket ();
s.bind (new InetSocketAddress (ipFrom, 0));
s.connect (new InetSocketAddress (ipTo, 80), 1000);
PrintWriter writer = new PrintWriter (s.getOutputStream ());
BufferedReader reader = new BufferedReader (new InputStreamReader (s.getInputStream ()));
writer.print ("GET " + szUrl + " HTTP/1.0\r\n\r\n");
writer.flush ();
s .close ();
reader.close ();
writer.close ();
}
但是,如您所见,我不发送自定义 HEADER。我应该添加什么来发送自定义 HEADER ?