mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	Add support for HEAD operations (#19520)
* Add header operation to sdk/logical Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com> * Add support for routing HEAD operations Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com> * Add changelog entry Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com> --------- Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
This commit is contained in:
		
							
								
								
									
										3
									
								
								changelog/19520.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								changelog/19520.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| ```release-note:improvement | ||||
| http: Support responding to HEAD operation from plugins | ||||
| ``` | ||||
| @@ -183,8 +183,10 @@ func buildLogicalRequestNoAuth(perfStandby bool, w http.ResponseWriter, r *http. | ||||
| 		} | ||||
|  | ||||
| 		data = parseQuery(r.URL.Query()) | ||||
|  | ||||
| 	case "OPTIONS", "HEAD": | ||||
| 	case "HEAD": | ||||
| 		op = logical.HeaderOperation | ||||
| 		data = parseQuery(r.URL.Query()) | ||||
| 	case "OPTIONS": | ||||
| 	default: | ||||
| 		return nil, nil, http.StatusMethodNotAllowed, nil | ||||
| 	} | ||||
|   | ||||
| @@ -369,6 +369,7 @@ const ( | ||||
| 	HelpOperation                     = "help" | ||||
| 	AliasLookaheadOperation           = "alias-lookahead" | ||||
| 	ResolveRoleOperation              = "resolve-role" | ||||
| 	HeaderOperation                   = "header" | ||||
|  | ||||
| 	// The operations below are called globally, the path is less relevant. | ||||
| 	RevokeOperation   Operation = "revoke" | ||||
|   | ||||
| @@ -20,7 +20,7 @@ import ( | ||||
| func RespondErrorCommon(req *Request, resp *Response, err error) (int, error) { | ||||
| 	if err == nil && (resp == nil || !resp.IsError()) { | ||||
| 		switch { | ||||
| 		case req.Operation == ReadOperation: | ||||
| 		case req.Operation == ReadOperation || req.Operation == HeaderOperation: | ||||
| 			if resp == nil { | ||||
| 				return http.StatusNotFound, nil | ||||
| 			} | ||||
|   | ||||
| @@ -42,6 +42,14 @@ func TestResponseUtil_RespondErrorCommon_basic(t *testing.T) { | ||||
| 			respErr:        nil, | ||||
| 			expectedStatus: 404, | ||||
| 		}, | ||||
| 		{ | ||||
| 			title: "Header not found", | ||||
| 			req: &Request{ | ||||
| 				Operation: HeaderOperation, | ||||
| 			}, | ||||
| 			respErr:        nil, | ||||
| 			expectedStatus: 404, | ||||
| 		}, | ||||
| 		{ | ||||
| 			title: "List with response and no keys", | ||||
| 			req: &Request{ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Alexander Scheel
					Alexander Scheel