001 package railo.commons.net.http.httpclient4.entity; 002 003 import org.apache.http.Header; 004 import org.apache.http.entity.ByteArrayEntity; 005 006 import railo.commons.lang.StringUtil; 007 008 public class ByteArrayHttpEntity extends ByteArrayEntity implements Entity4 { 009 010 011 private String strContentType; 012 private int contentLength; 013 014 public ByteArrayHttpEntity(byte[] barr, String contentType) { 015 super(barr); 016 contentLength=barr==null?0:barr.length; 017 018 if(StringUtil.isEmpty(contentType,true)) { 019 Header h = getContentType(); 020 if(h!=null) strContentType=h.getValue(); 021 } 022 else this.strContentType=contentType; 023 } 024 025 @Override 026 public long contentLength() { 027 return contentLength; 028 } 029 030 @Override 031 public String contentType() { 032 return strContentType; 033 } 034 035 }