Class HttpFileBuilder


  • public abstract class HttpFileBuilder
    extends AbstractHttpFileBuilder
    Builds an HttpFile from a file, a classpath resource or an HttpData.
    
     // Build from a file.
     HttpFile f = HttpFileBuilder.of(new File("/var/www/index.html"))
                                 .lastModified(false)
                                 .setHeader(HttpHeaderNames.CONTENT_LANGUAGE, "en-US")
                                 .build();
    
     // Build from a classpath resource.
     HttpFile f = HttpFileBuilder.ofResource(MyClass.class.getClassLoader(), "/foo.txt.gz")
                                 .setHeader(HttpHeaderNames.CONTENT_ENCODING, "gzip")
                                 .build();
    
     // Build from an HttpData. Can be downcast into AggregatedHttpFile.
     AggregatedHttpFile f = (AggregatedHttpFile)
             HttpFileBuilder.of(HttpData.ofUtf8("content"), System.currentTimeMillis())
                            .entityTag((pathOrUri, attrs) -> "myCustomEntityTag")
                            .build();