MCPcopy Index your code
hub / github.com/VictoriaMetrics/VictoriaLogs / abort

Method abort

lib/httpserver/httpserver.go:624–651  ·  view source on GitHub ↗

abort aborts the client connection associated with rwa. The last http chunk in the response stream is intentionally written incorrectly, so the client, which reads the response, could notice this error.

()

Source from the content-addressed store, hash-verified

622// The last http chunk in the response stream is intentionally written incorrectly,
623// so the client, which reads the response, could notice this error.
624func (rwa *responseWriterWithAbort) abort() {
625 if !rwa.sentHeaders {
626 logger.Panicf("BUG: abort can be called only after http response headers are sent")
627 }
628 if rwa.aborted {
629 // Nothing to do. The connection has been already aborted.
630 return
631 }
632 hj, ok := rwa.ResponseWriter.(http.Hijacker)
633 if !ok {
634 logger.Panicf("BUG: ResponseWriter must implement http.Hijacker interface")
635 }
636 conn, bw, err := hj.Hijack()
637 if err != nil {
638 logger.WarnfSkipframes(2, "cannot hijack response connection: %s", err)
639 return
640 }
641
642 // Just write an error message into the client connection as is without http chunked encoding.
643 // This is needed in order to notify the client about the aborted connection.
644 _, _ = bw.WriteString("\nthe connection has been aborted; see the last line in the response and/or in the server log for the reason\n")
645 _ = bw.Flush()
646
647 // Forcibly close the client connection in order to break http keep-alive at client side.
648 _ = conn.Close()
649
650 rwa.aborted = true
651}
652
653// Errorf writes formatted error message to w and to logger.
654func Errorf(w http.ResponseWriter, r *http.Request, format string, args ...any) {

Callers 15

ErrorfFunction · 0.80
fetchDataFunction · 0.80
useFetchLogsQLOptionsFunction · 0.80
useFetchExportFunction · 0.80
handleUpdateQueryFunction · 0.80
useLiveTailingLogsFunction · 0.80
useFetchLogHitsFunction · 0.80
useFetchLogsFunction · 0.80
useFetchQueryFunction · 0.80
fetchDataFunction · 0.80
useFetchQueryOptionsFunction · 0.80
CFunction · 0.80

Calls 4

PanicfFunction · 0.92
WarnfSkipframesFunction · 0.92
CloseMethod · 0.65
FlushMethod · 0.45

Tested by

no test coverage detected