mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2026-10-22 11:42:20 +00:00
Pull request 2489: AGDNS-3234-http-response-controller
Squashed commit of the following:
commit cbe1bf70e33022889b5bbae8c0ad4d90ddad43e0
Merge: 266f74d3d fbc4a2700
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Mon Sep 29 16:25:19 2025 +0300
Merge branch 'master' into AGDNS-3234-http-response-controller
commit 266f74d3d6ba9af9db86f0235634141b35acc26d
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Sep 25 17:27:38 2025 +0300
home: http response controller
This commit is contained in:
parent
fbc4a27007
commit
94d61abcc7
2 changed files with 13 additions and 5 deletions
|
|
@ -497,8 +497,11 @@ func (web *webAPI) handleInstallConfigure(w http.ResponseWriter, r *http.Request
|
|||
registerControlHandlers(web)
|
||||
|
||||
aghhttp.OK(w)
|
||||
if f, ok := w.(http.Flusher); ok {
|
||||
f.Flush()
|
||||
|
||||
rc := http.NewResponseController(w)
|
||||
err = rc.Flush()
|
||||
if err != nil {
|
||||
web.logger.WarnContext(ctx, "flushing response", slogutil.KeyError, err)
|
||||
}
|
||||
|
||||
if !restartHTTP {
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ func (web *webAPI) requestVersionInfo(
|
|||
|
||||
// handleUpdate performs an update to the latest available version procedure.
|
||||
func (web *webAPI) handleUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
updater := web.conf.updater
|
||||
if updater.NewVersion() == "" {
|
||||
aghhttp.Error(r, w, http.StatusBadRequest, "/update request isn't allowed now")
|
||||
|
|
@ -133,7 +135,7 @@ func (web *webAPI) handleUpdate(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
err = updater.Update(r.Context(), false)
|
||||
err = updater.Update(ctx, false)
|
||||
if err != nil {
|
||||
aghhttp.Error(r, w, http.StatusInternalServerError, "%s", err)
|
||||
|
||||
|
|
@ -141,8 +143,11 @@ func (web *webAPI) handleUpdate(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
aghhttp.OK(w)
|
||||
if f, ok := w.(http.Flusher); ok {
|
||||
f.Flush()
|
||||
|
||||
rc := http.NewResponseController(w)
|
||||
err = rc.Flush()
|
||||
if err != nil {
|
||||
web.logger.WarnContext(ctx, "flushing response", slogutil.KeyError, err)
|
||||
}
|
||||
|
||||
// The background context is used because the underlying functions wrap it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue