Use contants for CR and LF fields index
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
parent
5df1ad9b66
commit
386d9348ca
|
@ -143,6 +143,8 @@ public class ProxyConnectionFactory extends DetectorConnectionFactory
|
||||||
// 0 1 2 3 4 5 6
|
// 0 1 2 3 4 5 6
|
||||||
// 98765432109876543210987654321
|
// 98765432109876543210987654321
|
||||||
// PROXY P R.R.R.R L.L.L.L R Lrn
|
// PROXY P R.R.R.R L.L.L.L R Lrn
|
||||||
|
private static final int CR_INDEX = 6;
|
||||||
|
private static final int LF_INDEX = 7;
|
||||||
|
|
||||||
private final Connector _connector;
|
private final Connector _connector;
|
||||||
private final ConnectionFactory _next;
|
private final ConnectionFactory _next;
|
||||||
|
@ -167,7 +169,7 @@ public class ProxyConnectionFactory extends DetectorConnectionFactory
|
||||||
LOG.debug("Proxy v1 onFillable current index = ", _index);
|
LOG.debug("Proxy v1 onFillable current index = ", _index);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (_index < 7)
|
while (_index < LF_INDEX)
|
||||||
{
|
{
|
||||||
// Read data
|
// Read data
|
||||||
int fill = getEndPoint().fill(_buffer);
|
int fill = getEndPoint().fill(_buffer);
|
||||||
|
@ -207,7 +209,7 @@ public class ProxyConnectionFactory extends DetectorConnectionFactory
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (_index < 7)
|
while (_index < LF_INDEX)
|
||||||
{
|
{
|
||||||
if (!parse())
|
if (!parse())
|
||||||
{
|
{
|
||||||
|
@ -239,7 +241,7 @@ public class ProxyConnectionFactory extends DetectorConnectionFactory
|
||||||
public void onUpgradeTo(ByteBuffer prefilled)
|
public void onUpgradeTo(ByteBuffer prefilled)
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Proxy v1 copying prefilled buffer {}", prefilled);
|
LOG.debug("Proxy v1 copying prefilled buffer {}", BufferUtil.toDetailString(prefilled));
|
||||||
if (BufferUtil.hasContent(prefilled))
|
if (BufferUtil.hasContent(prefilled))
|
||||||
BufferUtil.append(_buffer, prefilled);
|
BufferUtil.append(_buffer, prefilled);
|
||||||
}
|
}
|
||||||
|
@ -257,14 +259,14 @@ public class ProxyConnectionFactory extends DetectorConnectionFactory
|
||||||
while (_buffer.hasRemaining())
|
while (_buffer.hasRemaining())
|
||||||
{
|
{
|
||||||
byte b = _buffer.get();
|
byte b = _buffer.get();
|
||||||
if (_index < 6)
|
if (_index < CR_INDEX)
|
||||||
{
|
{
|
||||||
if (b == ' ' || b == '\r')
|
if (b == ' ' || b == '\r')
|
||||||
{
|
{
|
||||||
_fields[_index++] = _builder.toString();
|
_fields[_index++] = _builder.toString();
|
||||||
_builder.setLength(0);
|
_builder.setLength(0);
|
||||||
if (b == '\r')
|
if (b == '\r')
|
||||||
_index = 6;
|
_index = CR_INDEX;
|
||||||
}
|
}
|
||||||
else if (b < ' ')
|
else if (b < ' ')
|
||||||
{
|
{
|
||||||
|
@ -279,7 +281,7 @@ public class ProxyConnectionFactory extends DetectorConnectionFactory
|
||||||
{
|
{
|
||||||
if (b == '\n')
|
if (b == '\n')
|
||||||
{
|
{
|
||||||
_index = 7;
|
_index = LF_INDEX;
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Proxy v1 parsing is done");
|
LOG.debug("Proxy v1 parsing is done");
|
||||||
return true;
|
return true;
|
||||||
|
@ -443,7 +445,7 @@ public class ProxyConnectionFactory extends DetectorConnectionFactory
|
||||||
public void onUpgradeTo(ByteBuffer prefilled)
|
public void onUpgradeTo(ByteBuffer prefilled)
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Proxy v2 copying prefilled buffer {}", prefilled);
|
LOG.debug("Proxy v2 copying prefilled buffer {}", BufferUtil.toDetailString(prefilled));
|
||||||
if (BufferUtil.hasContent(prefilled))
|
if (BufferUtil.hasContent(prefilled))
|
||||||
BufferUtil.append(_buffer, prefilled);
|
BufferUtil.append(_buffer, prefilled);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue