com.clouway.friendlyserve.RsWithHeader Maven / Gradle / Ivy
package com.clouway.friendlyserve;
import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.util.Collections;
import java.util.Map;
/**
* @author Miroslav Genov ([email protected])
*/
public class RsWithHeader extends RsWrap {
public RsWithHeader(String key, String value) {
this(new RsEmpty(), key, value);
}
public RsWithHeader(final Response res, final String key, final String value) {
super(new Response() {
@Override
public Iterable cookies() {
return Collections.emptyList();
}
@Override
public Status status() {
return new Status(HttpURLConnection.HTTP_OK);
}
@Override
public Map header() throws IOException {
return ImmutableMap.builder().putAll(res.header()).put(key, value).build();
}
@Override
public InputStream body() throws IOException {
return res.body();
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy