mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Merge pull request #14521 from mattmoor/authenticated-search
Add the X-Docker-Token header to the /v1/search requests.
This commit is contained in:
		
						commit
						c7d4a4b2b4
					
				
					 1 changed files with 8 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -676,7 +676,14 @@ func shouldRedirect(response *http.Response) bool {
 | 
			
		|||
func (r *Session) SearchRepositories(term string) (*SearchResults, error) {
 | 
			
		||||
	logrus.Debugf("Index server: %s", r.indexEndpoint)
 | 
			
		||||
	u := r.indexEndpoint.VersionString(1) + "search?q=" + url.QueryEscape(term)
 | 
			
		||||
	res, err := r.client.Get(u)
 | 
			
		||||
 | 
			
		||||
	req, err := http.NewRequest("GET", u, nil)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("Error while getting from the server: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
	// Have the AuthTransport send authentication, when logged in.
 | 
			
		||||
	req.Header.Set("X-Docker-Token", "true")
 | 
			
		||||
	res, err := r.client.Do(req)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue