本文整理汇总了Java中sun.net.www.MessageHeader.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java MessageHeader.getValue方法的具体用法?Java MessageHeader.getValue怎么用?Java MessageHeader.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.net.www.MessageHeader
的用法示例。
在下文中一共展示了MessageHeader.getValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRequests
import sun.net.www.MessageHeader; //导入方法依赖的package包/类
private void processRequests() throws Exception {
InputStream in = clientSocket.getInputStream();
MessageHeader response = new MessageHeader(in);
String statusLine = response.getValue(0);
if (statusLine.startsWith("CONNECT")) {
// retrieve the host and port info from the response line
retrieveConnectInfo(statusLine);
respondForConnect();
doTunnel();
ss.close();
} else {
System.out.println("proxy server: processes only "
+ "CONNECT method requests, recieved: "
+ statusLine);
}
}
示例2: run
import sun.net.www.MessageHeader; //导入方法依赖的package包/类
public void run() {
try {
Socket sock = ss.accept();
InputStream is = sock.getInputStream();
OutputStream os = sock.getOutputStream();
MessageHeader headers = new MessageHeader (is);
String requestLine = headers.getValue(0);
int first = requestLine.indexOf(' ');
int second = requestLine.lastIndexOf(' ');
String URIString = requestLine.substring(first+1, second);
URI requestURI = new URI(URIString);
if (requestURI.getFragment() != null)
os.write(replyFAILED.getBytes("UTF-8"));
else
os.write(replyOK.getBytes("UTF-8"));
sock.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: processRequest
import sun.net.www.MessageHeader; //导入方法依赖的package包/类
private void processRequest(Socket clientSocket) throws Exception {
MessageHeader mheader = new MessageHeader(clientSocket.getInputStream());
String statusLine = mheader.getValue(0);
if (!statusLine.startsWith("CONNECT")) {
out.println("proxy server: processes only "
+ "CONNECT method requests, recieved: "
+ statusLine);
return;
}
// retrieve the host and port info from the status-line
InetSocketAddress serverAddr = getConnectInfo(statusLine);
//open socket to the server
try (Socket serverSocket = new Socket(serverAddr.getAddress(),
serverAddr.getPort())) {
Forwarder clientFW = new Forwarder(clientSocket.getInputStream(),
serverSocket.getOutputStream());
Thread clientForwarderThread = new Thread(clientFW, "ClientForwarder");
clientForwarderThread.start();
send200(clientSocket);
Forwarder serverFW = new Forwarder(serverSocket.getInputStream(),
clientSocket.getOutputStream());
serverFW.run();
clientForwarderThread.join();
}
}
示例4: processRequests
import sun.net.www.MessageHeader; //导入方法依赖的package包/类
private void processRequests() throws IOException
{
InputStream in = clientSocket.getInputStream();
MessageHeader mheader = new MessageHeader(in);
String statusLine = mheader.getValue(0);
if (statusLine.startsWith("CONNECT")) {
// retrieve the host and port info from the status-line
retrieveConnectInfo(statusLine);
if (mheader.findValue("X-TestHeader") != null) {
System.out.println("Proxy should not receive user defined headers for tunneled requests");
failed = true;
}
// 6973030
String value;
if ((value = mheader.findValue("Proxy-Connection")) == null ||
!value.equals("keep-alive")) {
System.out.println("Proxy-Connection:keep-alive not being sent");
failed = true;
}
//This will allow the main thread to terminate without trying to perform the SSL handshake.
send400();
in.close();
clientSocket.close();
ss.close();
}
else {
System.out.println("proxy server: processes only "
+ "CONNECT method requests, recieved: "
+ statusLine);
}
}