Examples of HttpField


Examples of org.eclipse.jetty.http.HttpField

    public void testIndexes()
    {
        // Only enough space for 5 entries
        HpackContext ctx = new HpackContext(38*5);
       
        HttpField methodPost = new HttpField(":method","POST");
        HttpField[] field =
        {
           new HttpField("fo0","b0r"),
           new HttpField("fo1","b1r"),
           new HttpField("fo2","b2r"),
           new HttpField("fo3","b3r"),
           new HttpField("fo4","b4r"),
           new HttpField("fo5","b5r"),
           new HttpField("fo6","b6r"),
           new HttpField("fo7","b7r"),
           new HttpField("fo8","b8r"),
           new HttpField("fo9","b9r"),
           new HttpField("foA","bAr"),
        };
       
        Entry[] entry = new Entry[100];
       
        // Lookup the index of a static field
        assertEquals(0,ctx.size());
        assertEquals(":authority",ctx.get(1).getHttpField().getName());
        assertEquals(3,ctx.index(ctx.get(methodPost)));
        assertEquals(methodPost,ctx.get(3).getHttpField());
        assertEquals("www-authenticate",ctx.get(61).getHttpField().getName());
        assertEquals(null,ctx.get(62));
       
        // Add a single entry 
        entry[0]=ctx.add(field[0]);
       
        // Check new entry is 62
        assertEquals(1,ctx.size());
        assertEquals(62,ctx.index(entry[0]));
        assertEquals(entry[0],ctx.get(62));
       
        // and statics have moved up 0
        assertEquals(":authority",ctx.get(1+0).getHttpField().getName());
        assertEquals(3+0,ctx.index(ctx.get(methodPost)));
        assertEquals(methodPost,ctx.get(3+0).getHttpField());
        assertEquals("www-authenticate",ctx.get(61+0).getHttpField().getName());
        assertEquals(null,ctx.get(62+0+ctx.size()));
       

        // Add 4 more entries
        for (int i=1;i<=4;i++
            entry[i]=ctx.add(field[i]);

        // Check newest entry is at 62 oldest at 66
        assertEquals(5,ctx.size());
        int index=66;
        for (int i=0;i<=4;i++
        {
            assertEquals(index,ctx.index(entry[i]));
            assertEquals(entry[i],ctx.get(index));
            index--;
        }

        // and statics have moved up 0
        assertEquals(":authority",ctx.get(1+0).getHttpField().getName());
        assertEquals(3+0,ctx.index(ctx.get(methodPost)));
        assertEquals(methodPost,ctx.get(3+0).getHttpField());
        assertEquals("www-authenticate",ctx.get(61+0).getHttpField().getName());
        assertEquals(null,ctx.get(62+0+ctx.size()));
       
        // add 1 more entry and this should cause an eviction!
        entry[5]=ctx.add(field[5]);

        // Check newest entry is at 1 oldest at 5
        index=66;
        for (int i=1;i<=5;i++
        {
            assertEquals(index,ctx.index(entry[i]));
            assertEquals(entry[i],ctx.get(index));
            index--;
        }
        // check entry 0 evicted
        assertNull(ctx.get(field[0]));
        assertEquals(0,ctx.index(entry[0]));

        // and statics have moved up 0
        assertEquals(":authority",ctx.get(1+0).getHttpField().getName());
        assertEquals(3+0,ctx.index(ctx.get(methodPost)));
        assertEquals(methodPost,ctx.get(3+0).getHttpField());
        assertEquals("www-authenticate",ctx.get(61+0).getHttpField().getName());
        assertEquals(null,ctx.get(62+0+ctx.size()));
       
        // Add 4 more entries
        for (int i=6;i<=9;i++
            entry[i]=ctx.add(field[i]);
       
        // Check newest entry is at 1 oldest at 5
        index=66;
        for (int i=5;i<=9;i++
        {
            assertEquals(index,ctx.index(entry[i]));
            assertEquals(entry[i],ctx.get(index));
            index--;
        }
        // check entry 0-4 evicted
        for (int i=0;i<=4;i++)
        {
            assertNull(ctx.get(field[i]));
            assertEquals(0,ctx.index(entry[i]));
        }
       

        // Add new entries enough so that array queue will wrap
        for (int i=10;i<=52;i++)
            entry[i]=ctx.add(new HttpField("n"+i,"v"+i));

        index=66;
        for (int i=48;i<=52;i++
        {
            assertEquals(index,ctx.index(entry[i]));
View Full Code Here

Examples of org.eclipse.jetty.http.HttpField

    @Test
    public void testResize()
    {
        // Only enough space for 5 entries
        HpackContext ctx = new HpackContext(38*5);
        HttpField methodPost = new HttpField(":method","POST");
       
        HttpField[] field =
        {
           new HttpField("fo0","b0r"),
           new HttpField("fo1","b1r"),
           new HttpField("fo2","b2r"),
           new HttpField("fo3","b3r"),
           new HttpField("fo4","b4r"),
           new HttpField("fo5","b5r"),
           new HttpField("fo6","b6r"),
           new HttpField("fo7","b7r"),
           new HttpField("fo8","b8r"),
           new HttpField("fo9","b9r"),
           new HttpField("foA","bAr"),
        };
        Entry[] entry = new Entry[field.length];
       
        // Add 5 entries
        for (int i=0;i<=4;i++
View Full Code Here

Examples of org.eclipse.jetty.http.HttpField

        assertEquals("content-length",ctx.get("content-length").getHttpField().getName());
        assertEquals("content-length",ctx.get("Content-Length").getHttpField().getName());
        assertTrue(ctx.get("Content-Length").isStatic());
        assertTrue(ctx.get("Content-Type").isStatic());
       
        ctx.add(new HttpField("Wibble","Wobble"));
        assertEquals("Wibble",ctx.get("wibble").getHttpField().getName());
        assertEquals("Wibble",ctx.get("Wibble").getHttpField().getName());
       
    }
View Full Code Here

Examples of org.eclipse.jetty.http.HttpField

            if (request instanceof Request)
            {
                HttpFields fields = ((Request)request).getHttpFields();
                for (int i=fields.size();i-->0;)
                {
                    HttpField field=fields.getField(i);
                    if (field.getHeader() != null)
                    {
                        switch (field.getHeader())
                        {
                            case IF_MATCH:
                                ifm=field.getValue();
                                break;
                            case IF_NONE_MATCH:
                                ifnm=field.getValue();
                                break;
                            case IF_MODIFIED_SINCE:
                                ifms=field.getValue();
                                break;
                            case IF_UNMODIFIED_SINCE:
                                ifums=DateParser.parseDate(field.getValue());
                                break;
                            default:
                        }
                    }
                }
View Full Code Here

Examples of org.eclipse.jetty.http.HttpField

        }

        // If not HTTP/2, then we must check the accept encoding header
        if (request.getHttpVersion()!=HttpVersion.HTTP_2)
        {
            HttpField accept = request.getHttpFields().getField(HttpHeader.ACCEPT_ENCODING);

            if (accept==null)
            {
                LOG.debug("{} excluded !accept {}",this,request);
                return null;
            }
            boolean gzip = accept.contains("gzip");

            if (!gzip)
            {
                LOG.debug("{} excluded not gzip accept {}",this,request);
                return null;
View Full Code Here

Examples of org.eclipse.jetty.http.HttpField

        // remove any existing set-cookie fields of same name
        Iterator<HttpField> i=_fields.iterator();
        while (i.hasNext())
        {
            HttpField field=i.next();
            if (field.getHeader()==HttpHeader.SET_COOKIE)
            {
                String val = field.getValue();
                if (val!=null && val.startsWith(name_equals))
                {
                    //existing cookie has same name, does it also match domain and path?
                    if (((!has_domain && !val.contains("Domain")) || (has_domain && val.contains(domain))) &&
                        ((!has_path && !val.contains("Path")) || (has_path && val.contains(path))))
View Full Code Here

Examples of org.eclipse.jetty.http.HttpField

    }

    public void putHeaders(HttpContent content,long contentLength, boolean etag)
    {
       
        HttpField lm = content.getLastModified();
        if (lm!=null)
            _fields.put(lm);

        if (contentLength==0)
        {
            _fields.put(content.getContentLength());
            _contentLength=content.getContentLengthValue();
        }
        else if (contentLength>0)
        {
            _fields.putLongField(HttpHeader.CONTENT_LENGTH,contentLength);
            _contentLength=contentLength;
        }

        HttpField ct=content.getContentType();
        if (ct!=null)
        {
            _fields.put(ct);
            _contentType=ct.getValue();
            _characterEncoding=content.getCharacterEncoding();
            _mimeType=content.getMimeType();
        }
       
        if (etag)
        {
            HttpField et = content.getETag();
            if (et!=null)
                _fields.put(et);
        }
    }
View Full Code Here

Examples of org.eclipse.jetty.http.HttpField

    {
        final Request request = exchange.getRequest();
        final long idleTimeout = request.getIdleTimeout();
        short spdyVersion = getHttpChannel().getSession().getVersion();
        Fields fields = new Fields();
        HttpField hostHeader = null;
        for (HttpField header : request.getHeaders())
        {
            String name = header.getName();
            // The host header needs a special treatment
            if (HTTPSPDYHeader.from(spdyVersion, name) != HTTPSPDYHeader.HOST)
                fields.add(name, header.getValue());
            else
                hostHeader = header;
        }

        // Add special SPDY headers
        fields.put(HTTPSPDYHeader.METHOD.name(spdyVersion), request.getMethod());
        String path = request.getPath();
        String query = request.getQuery();
        if (query != null)
            path += "?" + query;
        fields.put(HTTPSPDYHeader.URI.name(spdyVersion), path);
        fields.put(HTTPSPDYHeader.VERSION.name(spdyVersion), request.getVersion().asString());
        if (hostHeader != null)
            fields.put(HTTPSPDYHeader.HOST.name(spdyVersion), hostHeader.getValue());

        SynInfo synInfo = new SynInfo(fields, !content.hasContent());
        getHttpChannel().getSession().syn(synInfo, getHttpChannel().getHttpReceiver(), new Promise<Stream>()
        {
            @Override
View Full Code Here

Examples of org.eclipse.jetty.http.HttpField

        }
       
        Entry(int index,String name, String value)
        {   
            _slot=index;
            _field=new HttpField(name,value);
        }
View Full Code Here

Examples of org.eclipse.jetty.http.HttpField

                    value=Huffman.decode(buffer,length);
                else
                    value=toASCIIString(buffer,length);

                // Make the new field
                HttpField field;
                if (header==null)
                {
                    // just make a normal field and bypass header name lookup
                    field = new HttpField(null,name,value);
                }
                else
                {
                    // might be worthwhile to create a value HttpField if it is indexed
                    // and/or of a type that may be looked up multiple times.
                    switch(header)
                    {
                        case C_STATUS:
                            if (indexed)
                                field = new HttpField.IntValueHttpField(header,name,value);
                            else
                                field = new HttpField(header,name,value);
                            break;

                        case C_AUTHORITY:
                            field = new AuthorityHttpField(value);
                            break;

                        case CONTENT_LENGTH:
                            if ("0".equals(value))
                                field = CONTENT_LENGTH_0;
                            else
                                field = new HttpField.LongValueHttpField(header,name,value);
                            break;

                        default:
                            field = new HttpField(header,name,value);
                            break;
                    }
                }

                if (LOG.isDebugEnabled())
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.