From 75d217b846bf4fe240ae25d9746da6d90daced8a Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Fri, 27 May 2016 16:38:09 +0500 Subject: [PATCH] Few fmt fixes --- proto/proto.go | 13 ++++++------- raw_socket_listener/tcp_message.go | 8 ++++---- raw_socket_listener/tcp_message_test.go | 6 +++--- settings.go | 4 ++-- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/proto/proto.go b/proto/proto.go index 314e190..07cf638 100644 --- a/proto/proto.go +++ b/proto/proto.go @@ -41,7 +41,6 @@ func MIMEHeadersStartPos(payload []byte) int { return bytes.Index(payload, CLRF) + 2 // Find first line end } - func isLower(b byte) bool { if 'a' <= b && b <= 'z' { return true @@ -82,10 +81,10 @@ func headerIndex(payload []byte, name []byte) int { } if payload[i] == name[0] || - (!isLower && payload[i] == toLower(name[0])) || - ( isLower && payload[i] == toUpper(name[0])) { + (!isLower && payload[i] == toLower(name[0])) || + (isLower && payload[i] == toUpper(name[0])) { - i++ + i++ j := 1 for { if j == len(name) { @@ -103,10 +102,10 @@ func headerIndex(payload []byte, name []byte) int { j++ if !(payload[i] == name[j] || - (!isLower && payload[i] == toLower(name[j])) || - ( isLower && payload[i] == toUpper(name[j]))) { + (!isLower && payload[i] == toLower(name[j])) || + (isLower && payload[i] == toUpper(name[j]))) { break - } + } } j++ diff --git a/raw_socket_listener/tcp_message.go b/raw_socket_listener/tcp_message.go index 4aa63b6..71c14ae 100644 --- a/raw_socket_listener/tcp_message.go +++ b/raw_socket_listener/tcp_message.go @@ -130,12 +130,12 @@ func (t *TCPMessage) isSeqMissing() bool { for i, p := range t.packets { // If final packet - if len(t.packets) == i + 1 { + if len(t.packets) == i+1 { return false } - np := t.packets[i + 1] + np := t.packets[i+1] - if np.Seq != p.Seq + uint32(len(p.Data)) { + if np.Seq != p.Seq+uint32(len(p.Data)) { return true } } @@ -216,7 +216,7 @@ func (t *TCPMessage) IsFinished() bool { if enc := proto.Header(payload, []byte("Transfer-Encoding")); len(enc) == 0 { return true } else { - if len(t.packets) > 1 && bytes.LastIndex(t.packets[len(t.packets) - 1].Data, ChunkEnd) != -1 { + if len(t.packets) > 1 && bytes.LastIndex(t.packets[len(t.packets)-1].Data, ChunkEnd) != -1 { return true } } diff --git a/raw_socket_listener/tcp_message_test.go b/raw_socket_listener/tcp_message_test.go index 7bdb715..2b90918 100644 --- a/raw_socket_listener/tcp_message_test.go +++ b/raw_socket_listener/tcp_message_test.go @@ -156,8 +156,8 @@ func TestTCPMessageIsFinished(t *testing.T) { func TestTCPMessageIsSeqMissing(t *testing.T) { p1 := buildPacket(false, 1, 1, []byte("HTTP/1.1 200 OK\r\n")) - p2 := buildPacket(false, 1, p1.Seq + uint32(len(p1.Data)), []byte("Content-Length: 10\r\n\r\n")) - p3 := buildPacket(false, 1, p2.Seq + uint32(len(p2.Data)), []byte("a")) + p2 := buildPacket(false, 1, p1.Seq+uint32(len(p1.Data)), []byte("Content-Length: 10\r\n\r\n")) + p3 := buildPacket(false, 1, p2.Seq+uint32(len(p2.Data)), []byte("a")) msg := buildMessage(p1) if msg.isSeqMissing() { @@ -177,7 +177,7 @@ func TestTCPMessageIsSeqMissing(t *testing.T) { func TestTCPMessageIsHeadersReceived(t *testing.T) { p1 := buildPacket(false, 1, 1, []byte("HTTP/1.1 200 OK\r\n")) - p2 := buildPacket(false, 1, p1.Seq + uint32(len(p1.Data)), []byte("Content-Length: 10\r\n\r\n")) + p2 := buildPacket(false, 1, p1.Seq+uint32(len(p1.Data)), []byte("Content-Length: 10\r\n\r\n")) msg := buildMessage(p1) if msg.isHeadersReceived() { diff --git a/settings.go b/settings.go index f77f564..24b253c 100644 --- a/settings.go +++ b/settings.go @@ -31,8 +31,8 @@ type AppSettings struct { splitOutput bool - inputDummy MultiOption - outputDummy MultiOption + inputDummy MultiOption + outputDummy MultiOption outputStdout bool inputTCP MultiOption