Changeset 29028342


Ignore:
Timestamp:
Feb 10, 2011 5:09:18 PM (9 years ago)
Author:
mathiasdm <mathiasdm@…>
Branches:
master
Children:
b43face
Parents:
c8866be
Message:

Extra test to check if headers with the same key are maintained.

Location:
apps/i2ptunnel/java
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java

    rc8866be r29028342  
    366366    }
    367367
    368     private static String formatHeaders(Map<String, List<String>> headers, StringBuilder command) {
     368    protected static String formatHeaders(Map<String, List<String>> headers, StringBuilder command) {
    369369        StringBuilder buf = new StringBuilder(command.length() + headers.size() * 64);
    370370        buf.append(command.toString().trim()).append("\r\n");
  • apps/i2ptunnel/java/test/net/i2p/i2ptunnel/I2PTunnelHTTPServerTest.java

    rc8866be r29028342  
    4242                assertEquals(headers.get("someHeader").size(), 2);
    4343        }
     44       
     45        public void testDuplicateHeadersFormat() throws IOException {
     46                String headerString = "GET /something HTTP/1.1\r\n";
     47                headerString += "abc: def\r\n";
     48                headerString += "abc: blaaah\r\n";
     49                headerString += "manamana: toe toe toedoedoe\r\n";
     50                headerString += "\r\n";
     51                InputStream in = fillInputStream(headerString);
     52                StringBuilder builder = new StringBuilder(128);
     53                Map<String, List<String>> headers = I2PTunnelHTTPServer.readHeaders(in, builder, new String[0], null);
     54                String result = I2PTunnelHTTPServer.formatHeaders(headers, builder);
     55                int first = result.indexOf("abc");
     56                assertTrue(first >= 0);
     57                int second = result.indexOf("abc", first);
     58                assertTrue(second >= 0);
     59        }
    4460
    4561}
Note: See TracChangeset for help on using the changeset viewer.