Example usage for io.netty.handler.codec.http HttpHeaders setDateHeader

List of usage examples for io.netty.handler.codec.http HttpHeaders setDateHeader

Introduction

In this page you can find the example usage for io.netty.handler.codec.http HttpHeaders setDateHeader.

Prototype

@Deprecated
public static void setDateHeader(HttpMessage message, CharSequence name, Iterable<Date> values) 

Source Link

Usage

From source file:io.reactivex.netty.protocol.http.server.HttpResponseHeaders.java

License:Apache License

public void setDateHeader(CharSequence name, Iterable<Date> values) {
    HttpHeaders.setDateHeader(nettyResponse, name, values);
}

From source file:io.reactivex.netty.protocol.http.server.HttpResponseHeaders.java

License:Apache License

public void setDateHeader(String name, Date value) {
    HttpHeaders.setDateHeader(nettyResponse, name, value);
}

From source file:io.reactivex.netty.protocol.http.server.HttpResponseHeaders.java

License:Apache License

public void setDateHeader(String name, Iterable<Date> values) {
    HttpHeaders.setDateHeader(nettyResponse, name, values);
}

From source file:org.ireland.jnetty.http.HttpServletResponseImpl.java

License:Open Source License

@Override
public void setDateHeader(String name, long date) {
    if (name == null || name.length() == 0) {
        return;//  ww  w .  ja  v a2  s . c  o  m
    }

    if (isCommitted()) {
        return;
    }

    // Ignore any call from an included servlet
    if (isIncluding()) {
        return;
    }

    HttpHeaders.setDateHeader(response, name, new Date(date));
}

From source file:org.ratpackframework.file.internal.FileHttpTransmitter.java

License:Apache License

public boolean transmit(final File targetFile, HttpResponse response, Channel channel) {
    final RandomAccessFile raf;
    try {/*from w ww. ja v  a2 s  .c o  m*/
        raf = new RandomAccessFile(targetFile, "r");
    } catch (FileNotFoundException fnfe) {
        throw new RuntimeException(fnfe);
    }

    long fileLength;
    try {
        fileLength = raf.length();
    } catch (IOException e) {
        closeQuietly(raf);
        throw new RuntimeException(e);
    }

    response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, fileLength);
    HttpHeaders.setDateHeader(response, HttpHeaders.Names.LAST_MODIFIED, new Date(targetFile.lastModified()));

    // Write the initial line and the header.
    if (!channel.isOpen()) {
        closeQuietly(raf);
        return false;
    }

    try {
        channel.write(response);
    } catch (Exception e) {
        closeQuietly(raf);
    }

    // Write the content.
    ChannelFuture writeFuture;

    ChunkedFile message = null;
    try {
        message = new ChunkedFile(raf, 0, fileLength, 8192);
        writeFuture = channel.write(message);
    } catch (Exception ignore) {
        if (channel.isOpen()) {
            channel.close();
        }
        if (message != null) {
            try {
                message.close();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return false;
    }

    final ChunkedFile finalMessage = message;
    writeFuture.addListener(new ChannelFutureListener() {
        public void operationComplete(ChannelFuture future) {
            try {
                finalMessage.close();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            future.addListener(ChannelFutureListener.CLOSE);
        }
    });

    return true;
}

From source file:reactor.io.net.impl.netty.http.NettyHttpResponseHeaders.java

License:Open Source License

@Override
public ResponseHeaders dateHeader(String name, Date value) {
    HttpHeaders.setDateHeader(this.nettyResponse, name, value);
    return this;
}

From source file:reactor.io.net.impl.netty.http.NettyHttpResponseHeaders.java

License:Open Source License

@Override
public ResponseHeaders dateHeader(String name, Iterable<Date> values) {
    HttpHeaders.setDateHeader(this.nettyResponse, name, values);
    return this;
}

From source file:rxweb.engine.server.netty.NettyResponseHeadersAdapter.java

License:Apache License

@Override
public ServerResponseHeaders dateHeader(String name, Date value) {
    HttpHeaders.setDateHeader(this.nettyResponse, name, value);
    return this;
}

From source file:rxweb.engine.server.netty.NettyResponseHeadersAdapter.java

License:Apache License

@Override
public ServerResponseHeaders dateHeader(String name, Iterable<Date> values) {
    HttpHeaders.setDateHeader(this.nettyResponse, name, values);
    return this;
}