Mercurial > stress-tester
changeset 678:77d613d85107
NC file in progress
author | Devel 2 |
---|---|
date | Tue, 21 Nov 2017 15:43:20 +0100 |
parents | ff5f3f3cdf60 |
children | 14e07598bc8c |
files | stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataReader.java stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java |
diffstat | 2 files changed, 32 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataReader.java Tue Nov 21 14:39:48 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataReader.java Tue Nov 21 15:43:20 2017 +0100 @@ -1,6 +1,11 @@ package com.passus.st.reader.nc; +import com.passus.data.ByteBuff; +import com.passus.data.ByteString; +import com.passus.data.DataHelper; +import com.passus.net.http.HttpHeaders; import com.passus.net.http.HttpMessage; +import static com.passus.st.reader.nc.NcHttpDataUtils.CUSTOM_HEADER_CODE; import java.io.IOException; /** @@ -9,6 +14,31 @@ */ public class HttpSessionPayloadEventDataReader { + private final NcDataHelper ncDataHelper = NcDataHelper.getInstance(); + + private final DataHelper dataHelper = DataHelper.BIG_ENDIAN; + + public HttpHeaders readHeaders(ByteBuff buffer) { + long headersSize = ncDataHelper.readLongVLC(buffer); + long readed = 0; + + HttpHeaders headers = new HttpHeaders(); + while (readed < headersSize) { + byte headerCode = buffer.read(); + ByteString headerName; + if (headerCode == CUSTOM_HEADER_CODE) { + headerName = ncDataHelper.readByteStringNullTerminated(buffer); + } else { + headerName = NcHttpDataUtils.codeToHeader(headerCode); + } + + ByteString headerValue = ncDataHelper.readByteStringNullTerminated(buffer); + headers.add(headerName, headerValue); + } + + return headers; + } + private HttpMessage read(NcDataBlockReader reader) throws IOException { return null; }
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java Tue Nov 21 14:39:48 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/HttpSessionPayloadEventDataWriter.java Tue Nov 21 15:43:20 2017 +0100 @@ -34,11 +34,11 @@ if (code == -1) { headersBuff.append(NcHttpDataUtils.CUSTOM_HEADER_CODE); ncDataHelper.writeByteStringNullTerminated(entry.getName(), headersBuff); - ncDataHelper.writeByteStringNullTerminated(entry.getValue(), headersBuff); } else { headersBuff.append((byte) code); - ncDataHelper.writeByteStringNullTerminated(entry.getValue(), headersBuff); } + + ncDataHelper.writeByteStringNullTerminated(entry.getValue(), headersBuff); } int len = headersBuff.readableBytes();