mirror of
https://github.com/gen2brain/cam2ip.git
synced 2025-12-13 02:48:31 +00:00
Update server
This commit is contained in:
@@ -33,6 +33,7 @@ func (j *JPEG) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
img, err := j.reader.Read()
|
||||
if err != nil {
|
||||
log.Printf("jpeg: read: %v", err)
|
||||
http.Error(w, "500 Internal Server Error", http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -40,6 +41,7 @@ func (j *JPEG) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
err = image.NewEncoder(w, j.quality).Encode(img)
|
||||
if err != nil {
|
||||
log.Printf("jpeg: encode: %v", err)
|
||||
http.Error(w, "500 Internal Server Error", http.StatusInternalServerError)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/abbot/go-http-auth"
|
||||
|
||||
@@ -63,7 +64,10 @@ func (s *Server) ListenAndServe() error {
|
||||
|
||||
http.Handle("/", newAuthHandler(handlers.NewIndex(), basic))
|
||||
|
||||
srv := &http.Server{}
|
||||
srv := &http.Server{
|
||||
ReadTimeout: 5 * time.Second,
|
||||
WriteTimeout: 5 * time.Second,
|
||||
}
|
||||
|
||||
listener, err := net.Listen("tcp", s.Bind)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user