mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-31 22:01:06 +00:00 
			
		
		
		
	updating github.com/emicklei/go-restful to v2.9.5+incompatible
This commit is contained in:
		
							
								
								
									
										49
									
								
								vendor/github.com/emicklei/go-restful/container.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										49
									
								
								vendor/github.com/emicklei/go-restful/container.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -97,7 +97,7 @@ func (c *Container) Add(service *WebService) *Container { | ||||
| 	// cannot have duplicate root paths | ||||
| 	for _, each := range c.webServices { | ||||
| 		if each.RootPath() == service.RootPath() { | ||||
| 			log.Printf("[restful] WebService with duplicate root path detected:['%v']", each) | ||||
| 			log.Printf("WebService with duplicate root path detected:['%v']", each) | ||||
| 			os.Exit(1) | ||||
| 		} | ||||
| 	} | ||||
| @@ -139,8 +139,8 @@ func (c *Container) addHandler(service *WebService, serveMux *http.ServeMux) boo | ||||
|  | ||||
| func (c *Container) Remove(ws *WebService) error { | ||||
| 	if c.ServeMux == http.DefaultServeMux { | ||||
| 		errMsg := fmt.Sprintf("[restful] cannot remove a WebService from a Container using the DefaultServeMux: ['%v']", ws) | ||||
| 		log.Printf(errMsg) | ||||
| 		errMsg := fmt.Sprintf("cannot remove a WebService from a Container using the DefaultServeMux: ['%v']", ws) | ||||
| 		log.Print(errMsg) | ||||
| 		return errors.New(errMsg) | ||||
| 	} | ||||
| 	c.webServicesLock.Lock() | ||||
| @@ -168,7 +168,7 @@ func (c *Container) Remove(ws *WebService) error { | ||||
| // This may be a security issue as it exposes sourcecode information. | ||||
| func logStackOnRecover(panicReason interface{}, httpWriter http.ResponseWriter) { | ||||
| 	var buffer bytes.Buffer | ||||
| 	buffer.WriteString(fmt.Sprintf("[restful] recover from panic situation: - %v\r\n", panicReason)) | ||||
| 	buffer.WriteString(fmt.Sprintf("recover from panic situation: - %v\r\n", panicReason)) | ||||
| 	for i := 2; ; i += 1 { | ||||
| 		_, file, line, ok := runtime.Caller(i) | ||||
| 		if !ok { | ||||
| @@ -220,20 +220,6 @@ func (c *Container) dispatch(httpWriter http.ResponseWriter, httpRequest *http.R | ||||
| 		}() | ||||
| 	} | ||||
|  | ||||
| 	// Detect if compression is needed | ||||
| 	// assume without compression, test for override | ||||
| 	if c.contentEncodingEnabled { | ||||
| 		doCompress, encoding := wantsCompressedResponse(httpRequest) | ||||
| 		if doCompress { | ||||
| 			var err error | ||||
| 			writer, err = NewCompressingResponseWriter(httpWriter, encoding) | ||||
| 			if err != nil { | ||||
| 				log.Print("[restful] unable to install compressor: ", err) | ||||
| 				httpWriter.WriteHeader(http.StatusInternalServerError) | ||||
| 				return | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	// Find best match Route ; err is non nil if no match was found | ||||
| 	var webService *WebService | ||||
| 	var route *Route | ||||
| @@ -245,6 +231,26 @@ func (c *Container) dispatch(httpWriter http.ResponseWriter, httpRequest *http.R | ||||
| 			c.webServices, | ||||
| 			httpRequest) | ||||
| 	}() | ||||
|  | ||||
| 	// Detect if compression is needed | ||||
| 	// assume without compression, test for override | ||||
| 	contentEncodingEnabled := c.contentEncodingEnabled | ||||
| 	if route != nil && route.contentEncodingEnabled != nil { | ||||
| 		contentEncodingEnabled = *route.contentEncodingEnabled | ||||
| 	} | ||||
| 	if contentEncodingEnabled { | ||||
| 		doCompress, encoding := wantsCompressedResponse(httpRequest) | ||||
| 		if doCompress { | ||||
| 			var err error | ||||
| 			writer, err = NewCompressingResponseWriter(httpWriter, encoding) | ||||
| 			if err != nil { | ||||
| 				log.Print("unable to install compressor: ", err) | ||||
| 				httpWriter.WriteHeader(http.StatusInternalServerError) | ||||
| 				return | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if err != nil { | ||||
| 		// a non-200 response has already been written | ||||
| 		// run container filters anyway ; they should not touch the response... | ||||
| @@ -259,7 +265,12 @@ func (c *Container) dispatch(httpWriter http.ResponseWriter, httpRequest *http.R | ||||
| 		chain.ProcessFilter(NewRequest(httpRequest), NewResponse(writer)) | ||||
| 		return | ||||
| 	} | ||||
| 	wrappedRequest, wrappedResponse := route.wrapRequestResponse(writer, httpRequest) | ||||
| 	pathProcessor, routerProcessesPath := c.router.(PathProcessor) | ||||
| 	if !routerProcessesPath { | ||||
| 		pathProcessor = defaultPathProcessor{} | ||||
| 	} | ||||
| 	pathParams := pathProcessor.ExtractParameters(route, webService, httpRequest.URL.Path) | ||||
| 	wrappedRequest, wrappedResponse := route.wrapRequestResponse(writer, httpRequest, pathParams) | ||||
| 	// pass through filters (if any) | ||||
| 	if len(c.containerFilters)+len(webService.filters)+len(route.Filters) > 0 { | ||||
| 		// compose filter chain | ||||
|   | ||||
		Reference in New Issue
	
	Block a user