Package org.eclipse.jetty.http

Examples of org.eclipse.jetty.http.HostPortHttpField


     * @param hostHeader
     *            The value of the host header to force.
     */
    public void setHostHeader(String hostHeader)
    {
        _hostHeader = new HostPortHttpField(hostHeader);
    }
View Full Code Here


            request.setAuthority(_hostHeader.getHost(),_hostHeader.getPort());
        }
        else if (forwardedHost != null)
        {
            // Update host header
            HostPortHttpField auth = new HostPortHttpField(forwardedHost);
            httpFields.put(auth);
            request.setAuthority(auth.getHost(),auth.getPort());
        }
        else if (forwardedServer != null)
        {
            // Use provided server name
            request.setAuthority(forwardedServer,request.getServerPort());
View Full Code Here

        // Return host from header field
        HttpField host = _metadata.getFields().getField(HttpHeader.HOST);
        if (host!=null)
        {
            // TODO is this needed now?
            HostPortHttpField authority = (host instanceof HostPortHttpField)
                ?((HostPortHttpField)host)
                :new HostPortHttpField(host.getValue());
            _metadata.getURI().setAuthority(authority.getHost(),authority.getPort());
            return authority.getHost();
        }

        // Return host from connection
        String name=getLocalName();
        if (name != null)
View Full Code Here

        // Return host from header field
        HttpField host = _metadata.getFields().getField(HttpHeader.HOST);
        if (host!=null)
        {
            // TODO is this needed now?
            HostPortHttpField authority = (host instanceof HostPortHttpField)
                ?((HostPortHttpField)host)
                :new HostPortHttpField(host.getValue());
            _metadata.getURI().setAuthority(authority.getHost(),authority.getPort());
            return authority.getPort();
        }

        // Return host from connection
        if (_channel != null)
            return getLocalPort();
View Full Code Here

                httpName.append(Character.toUpperCase(part.charAt(0)));
                httpName.append(part.substring(1).toLowerCase(Locale.ENGLISH));
            }
            String headerName = httpName.toString();
            if (HttpHeader.HOST.is(headerName))
                return new HostPortHttpField(field.getValue());
            else
                return new HttpField(httpName.toString(), field.getValue());
        }
        return null;
    }
View Full Code Here

        int streamId = 13;
        int promisedStreamId = 17;
        HttpFields fields = new HttpFields();
        fields.put("Accept", "text/html");
        fields.put("User-Agent", "Jetty");
        MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);

        // Iterate a few times to be sure generator and parser are properly reset.
        for (int i = 0; i < 2; ++i)
        {
            ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
View Full Code Here

        int streamId = 13;
        int promisedStreamId = 17;
        HttpFields fields = new HttpFields();
        fields.put("Accept", "text/html");
        fields.put("User-Agent", "Jetty");
        MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);

        ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
        generator.generatePushPromise(lease, streamId, promisedStreamId, metaData);

        for (ByteBuffer buffer : lease.getByteBuffers())
View Full Code Here

        int streamId = 13;
        HttpFields fields = new HttpFields();
        fields.put("Accept", "text/html");
        fields.put("User-Agent", "Jetty");
        MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);

        final List<HeadersFrame> frames = new ArrayList<>();
        Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
        {
            @Override
View Full Code Here

        int streamId = 13;
        HttpFields fields = new HttpFields();
        fields.put("Accept", "text/html");
        fields.put("User-Agent", "Jetty");
        MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);

        ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
        generator.generateHeaders(lease, streamId, metaData, false);

        for (ByteBuffer buffer : lease.getByteBuffers())
View Full Code Here

        if (LOG.isDebugEnabled())
            LOG.debug("HTTP > {} {} {}", httpMethod, uriHeader.getValue(), httpVersion);


        HostPortHttpField hostPort = null;
        HttpFields fields = new HttpFields();
        for (Fields.Field header : headers)
        {
            String name = header.getName();

            // Skip special SPDY headers, unless it's the "host" header
            HTTPSPDYHeader specialHeader = HTTPSPDYHeader.from(stream.getSession().getVersion(), name);
            if (specialHeader != null)
            {
                if (specialHeader != HTTPSPDYHeader.HOST)
                    continue;
                name = "host";
            }

            switch (name)
            {
                case "connection":
                case "keep-alive":
                case "proxy-connection":
                case "transfer-encoding":
                {
                    // Spec says to ignore these headers.
                    break;
                }
                case "host":
                {
                    hostPort = new HostPortHttpField(header.getValue());
                    break;
                }
                default:
                {
                    // Spec says headers must be single valued
                    String value = header.getValue();
                    if (LOG.isDebugEnabled())
                        LOG.debug("HTTP > {}: {}", name, value);
                    fields.add(new HttpField(name, value));
                    break;
                }
            }
        }

        if (hostPort == null)
        {
            onBadMessage(400, "Missing Host header");
            return false;
        }

        // At last, add the Host header.
        if (hostPort!=null)
            fields.add(hostPort);

        Fields.Field schemeHeader = headers.get(HTTPSPDYHeader.SCHEME.name(version));
       
        HttpURI uri = new HttpURI(uriHeader.getValue());
        if (uri.getScheme()==null && schemeHeader!=null)
            uri.setScheme(schemeHeader.getValue());
        if (uri.getHost()==null && hostPort!=null)
            uri.setAuthority(hostPort.getHost(),hostPort.getPort());
       
        MetaData.Request request = new MetaData.Request(httpMethod==null?methodHeader.getValue():httpMethod.asString(), uri, httpVersion, fields);
        onRequest(request);
        return true;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.http.HostPortHttpField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.