{title:'org.apache.juneau.http.resource', created:'9.0.0'}

The {@link oaj.http.resource} package contains implementations of {@link oaj.http.resource.HttpResource} which are extensions of org.apache.http.HttpEntity with arbitrary headers added.

- {@code org.apache.http.HttpEntity}
  - {@link oaj.http.resource.HttpResource}
    - {@link oaj.http.resource.BasicResource}
      - {@link oaj.http.resource.ByteArrayResource}
      - {@link oaj.http.resource.FileResource}
      - {@link oaj.http.resource.InputStreamResource}
      - {@link oaj.http.resource.ReaderResource}
      - {@link oaj.http.resource.StringResource}

##### HttpResourceBuilder

HTTP entities are created through builders created in the {@link oaj.http.HttpResources} class or individual create() methods defined in the subclasses above. The builder contains the following methods:

- {@link oaj.http.resource.HttpResourceBuilder}
  - {@link oaj.http.resource.HttpResourceBuilder#cached() cached()}
  - {@link oaj.http.resource.HttpResourceBuilder#chunked() chunked()}
  - {@link oaj.http.resource.HttpResourceBuilder#chunked(boolean) chunked(boolean)}
  - {@link oaj.http.resource.HttpResourceBuilder#content(Object) content(Object)}
  - {@link oaj.http.resource.HttpResourceBuilder#content(Supplier) content(Supplier)}
  - {@link oaj.http.resource.HttpResourceBuilder#contentEncoding(ContentEncoding) contentEncoding(ContentEncoding)}
  - {@link oaj.http.resource.HttpResourceBuilder#contentEncoding(String) contentEncoding(String)}
  - {@link oaj.http.resource.HttpResourceBuilder#contentLength(long) contentLength(long)}
  - {@link oaj.http.resource.HttpResourceBuilder#contentType(ContentType) contentType(ContentType)}
  - {@link oaj.http.resource.HttpResourceBuilder#contentType(String) contentType(String)}
  - {@link oaj.http.resource.HttpResourceBuilder#copyFrom(HttpResponse) copyFrom(HttpResponse)}
  - {@link oaj.http.resource.HttpResourceBuilder#getEntity() getEntity()}
  - {@link oaj.http.resource.HttpResourceBuilder#getHeaders() getHeaders()}
  - {@link oaj.http.resource.HttpResourceBuilder#header(Header) header(Header)}
  - {@link oaj.http.resource.HttpResourceBuilder#header(String,String) header(String,String)}
  - {@link oaj.http.resource.HttpResourceBuilder#headers(Header...) headers(Header...)}
  - {@link oaj.http.resource.HttpResourceBuilder#headers(HeaderList) headers(HeaderList)}
  - {@link oaj.http.resource.HttpResourceBuilder#headers(List) headers(List<Header>)}
  - {@link oaj.http.resource.HttpResourceBuilder#getHeaders() getHeaders()}

##### Example

| import static org.apache.juneau.http.HttpResources.*; | | byte[] payload = {...}; | | // Create via type builder. | HttpResource resource = ByteArrayResource | .create() | .content(payload) | .contentType(ContentType.APPLICATION_OCTET_STREAM) | .build(); | | // Create via HttpResources. | HttpResource resource = byteArrayResource(payload, ContentType.APPLICATION_OCTET_STREAM).build();