当前位置: 首页>>代码示例>>Java>>正文


Java MessageHeader.getValue方法代码示例

本文整理汇总了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);
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:ProxyTunnelServer.java

示例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();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:RequestURI.java

示例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();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:HttpProxy.java

示例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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:B6226610.java


注:本文中的sun.net.www.MessageHeader.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。