MCPcopy
hub / github.com/cubefs/cubefs / contentMiddleware

Method contentMiddleware

objectnode/api_middleware.go:198–207  ·  view source on GitHub ↗

ContentMiddleware returns a middleware handler to process reader for content. If the request contains the "X-amz-Decoded-Content-Length" header, it means that the data in the request body is chunked. Use ChunkedReader to parse the data.

(next http.Handler)

Source from the content-addressed store, hash-verified

196// If the request contains the "X-amz-Decoded-Content-Length" header, it means that the data
197// in the request body is chunked. Use ChunkedReader to parse the data.
198func (o *ObjectNode) contentMiddleware(next http.Handler) http.Handler {
199 var handlerFunc http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) {
200 if r.Header.Get(XAmzDecodedContentLength) != "" && r.Header.Get(ContentEncoding) != streamingContentEncoding {
201 r.Body = NewClosableChunkedReader(r.Body)
202 log.LogDebugf("contentMiddleware: chunk reader inited: requestID(%v)", GetRequestID(r))
203 }
204 next.ServeHTTP(w, r)
205 }
206 return handlerFunc
207}
208
209// Http's Expect header is a special header. When nginx is used as the reverse proxy in the front
210// end of ObjectNode, nginx will process the Expect header information in advance, send the http

Callers

nothing calls this directly

Calls 5

LogDebugfFunction · 0.92
NewClosableChunkedReaderFunction · 0.85
GetRequestIDFunction · 0.85
GetMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected