Few fmt fixes

This commit is contained in:
Leonid Bugaev
2016-05-27 16:38:09 +05:00
parent c1f354a01c
commit 75d217b846
4 changed files with 15 additions and 16 deletions
+6 -7
View File
@@ -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++
+4 -4
View File
@@ -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
}
}
+3 -3
View File
@@ -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() {
+2 -2
View File
@@ -31,8 +31,8 @@ type AppSettings struct {
splitOutput bool
inputDummy MultiOption
outputDummy MultiOption
inputDummy MultiOption
outputDummy MultiOption
outputStdout bool
inputTCP MultiOption