mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-04-25 12:56:23 +02:00
switch to Apache 2.0 license before release
This commit is contained in:
parent
b165ea8f12
commit
ea76f2d0d8
10 changed files with 295 additions and 30 deletions
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2013 Google Inc. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package proxy provides the image proxy.
|
||||
package proxy
|
||||
|
||||
|
|
@ -87,7 +101,8 @@ func NewProxy(client *http.Client) *Proxy {
|
|||
func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
req, err := NewRequest(r)
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("invalid request URL: %v", err.Error()), http.StatusBadRequest)
|
||||
glog.Errorf("invalid request URL: %v", err)
|
||||
http.Error(w, fmt.Sprintf("invalid request URL: %v", err), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +117,8 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
glog.Infof("request for image: %v", u)
|
||||
|
||||
if !p.allowed(req.URL) {
|
||||
http.Error(w, fmt.Sprintf("remote URL is not for an allowed host: %v", req.URL.Host), http.StatusForbidden)
|
||||
glog.Errorf("remote URL is not for an allowed host: %v", req.URL.Host)
|
||||
http.Error(w, fmt.Sprintf("remote URL is not for an allowed host: %v", req.URL.Host), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -111,14 +127,14 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
glog.Infof("image not cached")
|
||||
image, err = p.fetchRemoteImage(u, nil)
|
||||
if err != nil {
|
||||
glog.Errorf("errorf fetching remote image: %v", err)
|
||||
glog.Errorf("error fetching remote image: %v", err)
|
||||
}
|
||||
p.Cache.Save(image)
|
||||
} else if time.Now().After(image.Expires) {
|
||||
glog.Infof("cached image expired")
|
||||
image, err = p.fetchRemoteImage(u, image)
|
||||
if err != nil {
|
||||
glog.Errorf("errorf fetching remote image: %v", err)
|
||||
glog.Errorf("error fetching remote image: %v", err)
|
||||
}
|
||||
p.Cache.Save(image)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue