Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2016 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.reactivex.netty.protocol.http.server;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpUtil;
import io.netty.handler.codec.http.cookie.Cookie;
import io.netty.handler.codec.http.cookie.ServerCookieEncoder;
import io.reactivex.netty.channel.AllocatingTransformer;
import io.reactivex.netty.channel.ChannelOperations;
import io.reactivex.netty.channel.Connection;
import io.reactivex.netty.channel.MarkAwarePipeline;
import io.reactivex.netty.protocol.http.HttpHandlerNames;
import io.reactivex.netty.protocol.http.TrailingHeaders;
import io.reactivex.netty.protocol.http.sse.ServerSentEvent;
import io.reactivex.netty.protocol.http.sse.server.ServerSentEventEncoder;
import io.reactivex.netty.protocol.http.ws.server.WebSocketHandler;
import io.reactivex.netty.protocol.http.ws.server.WebSocketHandshaker;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Func0;
import rx.functions.Func1;
import rx.functions.Func2;
import java.util.Date;
import java.util.List;
import java.util.Set;
public final class HttpServerResponseImpl extends HttpServerResponse {
private final State state;
private HttpServerResponseImpl(final State state) {
super(new OnSubscribe() {
@Override
public void call(Subscriber super Void> subscriber) {
state.sendHeaders().write(Observable.empty()).unsafeSubscribe(subscriber);
}
});
this.state = state;
}
@Override
public HttpResponseStatus getStatus() {
return state.headers.status();
}
@Override
public boolean containsHeader(CharSequence name) {
return state.headers.headers().contains(name);
}
@Override
public boolean containsHeader(CharSequence name, CharSequence value, boolean ignoreCaseValue) {
return state.headers.headers().contains(name, value, ignoreCaseValue);
}
@Override
public String getHeader(CharSequence name) {
return state.headers.headers().get(name);
}
@Override
public String getHeader(CharSequence name, String defaultValue) {
return state.headers.headers().get(name, defaultValue);
}
@Override
public List getAllHeaderValues(CharSequence name) {
return state.headers.headers().getAll(name);
}
@Override
public long getDateHeader(CharSequence name) {
return state.headers.headers().getTimeMillis(name);
}
@Override
public long getDateHeader(CharSequence name, long defaultValue) {
return state.headers.headers().getTimeMillis(name, defaultValue);
}
@Override
public int getIntHeader(CharSequence name) {
return state.headers.headers().getInt(name);
}
@Override
public int getIntHeader(CharSequence name, int defaultValue) {
return state.headers.headers().getInt(name, defaultValue);
}
@Override
public Set getHeaderNames() {
return state.headers.headers().names();
}
@Override
public HttpServerResponse addHeader(CharSequence name, Object value) {
if (state.allowUpdate()) {
state.headers.headers().add(name, value);
}
return this;
}
@Override
public HttpServerResponse addCookie(Cookie cookie) {
if (state.allowUpdate()) {
state.headers.headers().add(HttpHeaderNames.SET_COOKIE, ServerCookieEncoder.STRICT.encode(cookie));
}
return this;
}
@Override
public HttpServerResponse addDateHeader(CharSequence name, Date value) {
if (state.allowUpdate()) {
state.headers.headers().add(name, value);
}
return this;
}
@Override
public HttpServerResponse addDateHeader(CharSequence name, Iterable values) {
if (state.allowUpdate()) {
for (Date value : values) {
state.headers.headers().add(name, value);
}
}
return this;
}
@Override
public HttpServerResponse addHeader(CharSequence name, Iterable