Http's Expect header is a special header. When nginx is used as the reverse proxy in the front end of ObjectNode, nginx will process the Expect header information in advance, send the http status code 100 to the client, and will not forward this header information to ObjectNode. At this time, if the
(next http.Handler)
| 219 | // the original value of Expect to the ObjectNode through X-Forwarded-Expect. ObjectNode only |
| 220 | // needs to use the value of X-Forwarded-Expect. |
| 221 | func (o *ObjectNode) expectMiddleware(next http.Handler) http.Handler { |
| 222 | var handlerFunc http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) { |
| 223 | defer func() { |
| 224 | // panic recover and response specific status to client |
| 225 | p := recover() |
| 226 | if p != nil { |
| 227 | log.LogErrorf("panic(%v): requestID(%v) stack(%v)", p, GetRequestID(r), string(debug.Stack())) |
| 228 | w.WriteHeader(StatusServerPanic) |
| 229 | } |
| 230 | }() |
| 231 | if forwarded, origin := r.Header.Get(XForwardedExpect), r.Header.Get(Expect); forwarded != "" && origin == "" { |
| 232 | r.Header.Set(Expect, forwarded) |
| 233 | } |
| 234 | next.ServeHTTP(w, r) |
| 235 | } |
| 236 | return handlerFunc |
| 237 | } |
| 238 | |
| 239 | // CORSMiddleware returns a middleware handler to support CORS request. |
| 240 | // This handler will write following header into response: |
nothing calls this directly
no test coverage detected