Improved performance
This commit is contained in:
parent
5af7efcdbd
commit
adb1d0beb2
11
Server.go
11
Server.go
@ -2,12 +2,14 @@ package web
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -209,7 +211,14 @@ func (s *server) handleRequest(ctx *context, method string, url string, writer i
|
|||||||
s.errorHandler(ctx, err)
|
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.
|
// newContext allocates a new context with the default state.
|
||||||
|
Loading…
Reference in New Issue
Block a user