Java Code Examples for org.eclipse.jetty.websocket.common.io.http.HttpResponseHeaderParser

Following code examples demonstrate how to use org.eclipse.jetty.websocket.common.io.http.HttpResponseHeaderParser from jetty. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.eclipse.jetty.websocket.common.io.http.HttpResponseHeaderParser and various code implementation of this class.

        @Override
        public void failed(Throwable cause)
        {
            super.failed(cause);
            connectPromise.failed(cause);
        } 


    }

    public HttpResponse readResponseHeader() throws IOException
    {
        HttpResponse response = new HttpResponse();
        HttpResponseHeaderParser respParser = new HttpResponseHeaderParser(response);

        byte buf[] = new byte[512];

        while (!eof)
        {
            int available = in.available();
            int len = in.read(buf,0,Math.min(available,buf.length));
            if (len < 0)
            {
                eof = true;
                break;
            }
            else if (len > 0)
            {
                ByteBuffer bbuf = ByteBuffer.wrap(buf,0,len);
                if (LOG.isDebugEnabled())
                {
                    LOG.debug("Read {} bytes: {}",len,BufferUtil.toDetailString(bbuf));
                }
                if (respParser.parse(bbuf) != null)
                {
                    break;
                }
            }
        }

        remainingBuffer = response.getRemainingBuffer();

        return response;
    } 

Advertisement
Javadoc
Responsible for reading UTF8 Response Header lines and parsing them into a provided UpgradeResponse

object.

Read More
Advertisement