Improved performance
This commit is contained in:
parent
d80b6c1edb
commit
892dce8979
1 changed files with 10 additions and 1 deletions
11
Server.go
11
Server.go
|
@ -2,12 +2,14 @@ package web
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
@ -209,7 +211,14 @@ func (s *server) handleRequest(ctx *context, method string, url string, writer i
|
|||
s.errorHandler(ctx, err)
|
||||
}
|
||||
|
||||
fmt.Fprintf(writer, "HTTP/1.1 %d\r\nContent-Length: %d\r\n%s\r\n%s", ctx.status, len(ctx.response.body), ctx.response.headerText(), ctx.response.body)
|
||||
tmp := bytes.Buffer{}
|
||||
tmp.WriteString("HTTP/1.1 ")
|
||||
tmp.WriteString(strconv.Itoa(int(ctx.status)))
|
||||
tmp.WriteString("\r\nContent-Length: ")
|
||||
tmp.WriteString(strconv.Itoa(len(ctx.response.body)))
|
||||
tmp.WriteString("\r\n\r\n")
|
||||
tmp.Write(ctx.response.body)
|
||||
writer.Write(tmp.Bytes())
|
||||
}
|
||||
|
||||
// newContext allocates a new context with the default state.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue