From 84aa38ffee2d2fe7f297f25f01acf8754e6cf459 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Thu, 6 Jul 2017 17:16:02 +0200 Subject: [PATCH] inline HEADER_LENGTH --- .../src/org/jetbrains/io/fastCgi/FastCgiConstants.java | 5 ----- .../src/org/jetbrains/io/fastCgi/FastCgiDecoder.kt | 4 +++- .../src/org/jetbrains/io/fastCgi/FastCgiRequest.kt | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiConstants.java diff --git a/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiConstants.java b/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiConstants.java deleted file mode 100644 index 23a85dead1f9..000000000000 --- a/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiConstants.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.jetbrains.io.fastCgi; - -public final class FastCgiConstants { - public static final int HEADER_LENGTH = 8; -} \ No newline at end of file diff --git a/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiDecoder.kt b/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiDecoder.kt index 271bf69af3f8..60f320e6fec2 100644 --- a/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiDecoder.kt +++ b/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiDecoder.kt @@ -8,6 +8,8 @@ import io.netty.channel.ChannelHandlerContext import io.netty.util.CharsetUtil import org.jetbrains.io.Decoder +internal const val HEADER_LENGTH = 8 + internal class FastCgiDecoder(private val errorOutputConsumer: Consumer, private val responseHandler: FastCgiService) : Decoder(), Decoder.FullMessageConsumer { private enum class State { HEADER, @@ -52,7 +54,7 @@ internal class FastCgiDecoder(private val errorOutputConsumer: Consumer, } } - val buffer = getBufferIfSufficient(input, FastCgiConstants.HEADER_LENGTH, context) ?: return + val buffer = getBufferIfSufficient(input, HEADER_LENGTH, context) ?: return decodeHeader(buffer) state = State.CONTENT diff --git a/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiRequest.kt b/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiRequest.kt index 1fe1f0f294f0..0dc119161207 100644 --- a/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiRequest.kt +++ b/platform/built-in-server/src/org/jetbrains/io/fastCgi/FastCgiRequest.kt @@ -23,7 +23,7 @@ class FastCgiRequest(val requestId: Int, allocator: ByteBufAllocator) { private var buffer: ByteBuf? = allocator.ioBuffer(4096) init { - writeHeader(buffer!!, BEGIN_REQUEST, FastCgiConstants.HEADER_LENGTH) + writeHeader(buffer!!, BEGIN_REQUEST, HEADER_LENGTH) buffer!!.writeShort(RESPONDER) buffer!!.writeByte(FCGI_KEEP_CONNECTION) // reserved[5] @@ -128,7 +128,7 @@ class FastCgiRequest(val requestId: Int, allocator: ByteBufAllocator) { // channel.write releases releaseContent = false - val headerBuffer = fastCgiChannel.alloc().ioBuffer(FastCgiConstants.HEADER_LENGTH, FastCgiConstants.HEADER_LENGTH) + val headerBuffer = fastCgiChannel.alloc().ioBuffer(HEADER_LENGTH, HEADER_LENGTH) writeHeader(headerBuffer, STDIN, 0) fastCgiChannel.write(headerBuffer) }