Examples of Headers


Examples of br.com.caelum.restfulie.http.Headers

  private RestClient client;
 
  @Test
  public void shouldGetJustTheFirstInformation()
  {
    Headers headers = new ApacheHeaders(response, client);
   
    when(response.getHeaders("Content-Type")).thenReturn(headers());
    assertEquals("text/html", headers.getMain("Content-Type"));
  }
View Full Code Here

Examples of com.ettrema.zsync.HeaderMaker.Headers

  /**
   * Method reads metafile from file and reads
   * it line by line, sending line String to parser.
   */
  private void readMetaFile(File metafile) {
    headers = new Headers();
    try {
      BufferedReader in = new BufferedReader(new FileReader(metafile));
      String s;
      while ((s = in.readLine()) != null) {
        if (parseHeader(s)) {
View Full Code Here

Examples of com.example.types.Headers

    @Test
    public void test() throws Exception {
        TestBindingStub stub = (TestBindingStub)port;
        stub.setHeader(
            "http://example.com/", "headers",
            (new Headers("user", "pass")));
        Assert.assertEquals("hello user", port.say_hello());
    }
View Full Code Here

Examples of com.jayway.restassured.response.Headers

            .get("/resource");

        String tmp = response.getHeader("X-collection-size");
        int pagingTotalSize = Integer.parseInt(tmp);

        Headers responseHeaders = response.getHeaders();
        List<String> headers = responseHeaders.getValues("Link");
        tmp = null;
        for (String header : headers) {
            if (header.contains("rel=\"last\"")) {
                tmp = header;
                break;
View Full Code Here

Examples of com.sun.net.httpserver.Headers

     * Returns the String value of the specified cookie.
     * @param name a String specifying the cookie name.
     */
    public String getCookie(final String name)
    {
        Headers headers = _exchange.getRequestHeaders();
        if (!headers.containsKey("Cookie"))
        {
            return null;
        }

        List<String> values = headers.get("cookie");
        for (String value : values)
        {
            String[] cookies = value.split(";");
            for (String cookie : cookies)
            {
View Full Code Here

Examples of com.sun.net.httpserver.Headers

    ExchangeImpl (
        String m, URI u, Request req, long len, HttpConnection connection
    ) throws IOException {
        this.req = req;
        this.reqHdrs = req.headers();
        this.rspHdrs = new Headers();
        this.method = m;
        this.uri = u;
        this.connection = connection;
        this.reqContentLen = len;
        /* ros only used for headers, body written directly to stream */
 
View Full Code Here

Examples of com.sun.net.httpserver.Headers

                }
                String uriStr = requestLine.substring (start, space);
                URI uri = new URI (uriStr);
                start = space+1;
                String version = requestLine.substring (start);
                Headers headers = req.headers();
                String s = headers.getFirst ("Transfer-encoding");
                long clen = 0L;
                if (s !=null && s.equalsIgnoreCase ("chunked")) {
                    clen = -1L;
                } else {
                    s = headers.getFirst ("Content-Length");
                    if (s != null) {
                        clen = Long.parseLong(s);
                    }
                }
                ctx = contexts.findContext (protocol, uri.getPath());
                if (ctx == null) {
                    reject (Code.HTTP_NOT_FOUND,
                            requestLine, "No context found for request");
                    return;
                }
                connection.setContext (ctx);
                if (ctx.getHandler() == null) {
                    reject (Code.HTTP_INTERNAL_ERROR,
                            requestLine, "No handler for context");
                    return;
                }
                tx = new ExchangeImpl (
                    method, uri, req, clen, connection
                );
                String chdr = headers.getFirst("Connection");
                Headers rheaders = tx.getResponseHeaders();

                if (chdr != null && chdr.equalsIgnoreCase ("close")) {
                    tx.close = true;
                }
                if (version.equalsIgnoreCase ("http/1.0")) {
                    tx.http10 = true;
                    if (chdr == null) {
                        tx.close = true;
                        rheaders.set ("Connection", "close");
                    } else if (chdr.equalsIgnoreCase ("keep-alive")) {
                        rheaders.set ("Connection", "keep-alive");
                        int idle=(int)ServerConfig.getIdleInterval()/1000;
                        int max=(int)ServerConfig.getMaxIdleConnections();
                        String val = "timeout="+idle+", max="+max;
                        rheaders.set ("Keep-Alive", val);
                    }
                }

                if (newconnection) {
                    connection.setParameters (
View Full Code Here

Examples of com.sun.net.httpserver.Headers

    Headers headers () throws IOException {
        if (hdrs != null) {
            return hdrs;
        }
        hdrs = new Headers();

        char s[] = new char[10];
        int firstc = is.read();
        while (firstc != LF && firstc != CR && firstc >= 0) {
            int len = 0;
View Full Code Here

Examples of com.sun.net.httpserver.Headers

    {
        public void handle(HttpExchange exchange) throws IOException
        {
            assertEquals("HTTP/1.1", exchange.getProtocol());
            assertEquals("POST", exchange.getRequestMethod());
            Headers headers = exchange.getRequestHeaders();
            assertTrue (headers.containsKey("foo"));
            String val = headers.getFirst("foo");
         
            assertEquals ("fooValue", val);
            assertNotNull (exchange.getHttpContext());
            assertEquals ("/foo", exchange.getHttpContext().getPath());
            assertTrue (this == exchange.getHttpContext().getHandler());
            assertTrue (exchange.getHttpContext().getAttributes().containsKey("fooAttribute"));
            assertEquals("fooValue", (String)exchange.getHttpContext().getAttributes().get("fooAttribute"));
          
            assertEquals ("Was Here", (String)exchange.getAttribute("fooFilter"));
            assertEquals ("Was Also Here", (String)exchange.getAttribute("barFilter"));
           
            assertNotNull(exchange.getPrincipal());
            assertEquals("humpty", exchange.getPrincipal().getName());
           
            String response = "Hello World!";
            InputStream is = exchange.getRequestBody();
            String body = IO.toString(is);
            assertEquals(0, body.length());
           
            Headers responseHeaders = exchange.getResponseHeaders();
            responseHeaders.add("bar", "barValue");
            exchange.sendResponseHeaders(200, response.length());
            OutputStream os = exchange.getResponseBody();
            os.write(response.getBytes());
            os.close();
        }
View Full Code Here

Examples of com.sun.net.httpserver.Headers

    }

    @Override
    public Headers getRequestHeaders()
    {
        Headers headers = new Headers();
        Enumeration en = _req.getHeaderNames();
        while (en.hasMoreElements())
        {
            String name = (String) en.nextElement();
            Enumeration en2 = _req.getHeaders(name);
            while (en2.hasMoreElements())
            {
                String value = (String) en2.nextElement();
                headers.add(name, value);
            }
        }
        return headers;
    }
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.