
org.webpieces.httpparser.api.dto.HttpMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http-parser1_1 Show documentation
Show all versions of http-parser1_1 Show documentation
A re-usable asynchronous http 1.1 parser that can be used with any nio client
The newest version!
package org.webpieces.httpparser.api.dto;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.webpieces.httpparser.api.common.Header;
import org.webpieces.httpparser.api.common.KnownHeaderName;
public abstract class HttpMessage extends HttpPayload {
protected List headers = new ArrayList<>();
//Convenience structure that further morphs the headers into a Map that can
//be looked up by key.
private transient Headers headersStruct = new Headers();
/**
* Order of HTTP Headers matters for Headers with the same key
*/
public List getHeaders() {
return Collections.unmodifiableList(headers);
}
public void addHeader(Header header) {
headers.add(header);
headersStruct.addHeader(header);
}
/**
*
* @return
*/
public Headers getHeaderLookupStruct() {
return headersStruct;
}
public boolean isHasChunkedTransferHeader() {
//need to account for a few Transfer Encoding headers
Header header = headersStruct.getLastInstanceOfHeader(KnownHeaderName.TRANSFER_ENCODING);
if(header != null && "chunked".equals(header.getValue()))
return true;
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy