<commit_before>/*
 * Copyright (c) 2011-2016 Pivotal Software Inc, All Rights Reserved.
 *
 * 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 reactor.io.netty.http;

import java.net.URI;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultHttpRequest;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.util.ReferenceCountUtil;
import reactor.core.publisher.Flux;

/**
 * @author <NAME>
 */
final class NettyWebSocketClientHandler extends NettyHttpClientHandler {

	final WebSocketClientHandshaker handshaker;

	final ChannelPromise handshakerResult;

	final boolean plainText;

	NettyWebSocketClientHandler(
			String protocols,
			NettyHttpClientHandler originalHandler,
			boolean plainText) {
		super(originalHandler.getHandler(), originalHandler.tcpStream, originalHandler.currentURI);
		this.httpChannel = originalHandler.httpChannel;
		this.replySubscriber = originalHandler.replySubscriber;
		this.plainText = plainText;

		handshaker =
				WebSocketClientHandshakerFactory.newHandshaker(currentURI,
						WebSocketVersion.V13,
						protocols,
						false,
						httpChannel.headers());

		handshakerResult = httpChannel.delegate().newPromise();<commit_msg>remove transfer chunk on http websocket<commit_after>/*
 * Copyright (c) 2011-2016 Pivotal Software Inc, All Rights Reserved.
 *
 * 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 reactor.io.netty.http;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.util.ReferenceCountUtil;
import reactor.core.publisher.Flux;

/**
 * @author <NAME>
 */
final class NettyWebSocketClientHandler extends NettyHttpClientHandler {

	final WebSocketClientHandshaker handshaker;

	final ChannelPromise handshakerResult;

	final boolean plainText;

	NettyWebSocketClientHandler(
			String protocols,
			NettyHttpClientHandler originalHandler,
			boolean plainText) {
		super(originalHandler.getHandler(), originalHandler.tcpStream, originalHandler.currentURI);
		this.httpChannel = originalHandler.httpChannel;
		this.replySubscriber = originalHandler.replySubscriber;
		this.plainText = plainText;

		handshaker =
				WebSocketClientHandshakerFactory.newHandshaker(currentURI,
						WebSocketVersion.V13,
						protocols,
						false,
						httpChannel.removeTransferEncodingChunked().headers());

		handshakerResult = httpChannel.delegate().newPromise();
{'fraction_non_alphanumeric': 0.08695652173913043, 'fraction_numerical': 0.005742411812961444, 'mean_word_length': 5.2525641025641026, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3440198', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1384, 'n_words': 334}