Skip to content

Commit e62ec77

Browse files
committed
chore(backend): remove proxy symbol method from ingest service
fixes #3275 Signed-off-by: detj <detj@users.noreply.github.com>
1 parent 8aab60a commit e62ec77

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

backend/ingest/measure/build.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"net/http"
7-
"net/http/httputil"
87
"net/url"
98
"path/filepath"
109
"strings"
@@ -424,63 +423,3 @@ func PutBuilds(c *gin.Context) {
424423
"mappings": build.Mappings,
425424
})
426425
}
427-
428-
// ProxySymbol proxies presigned S3 URLs to an S3-like
429-
// server.
430-
//
431-
// We parse the payload from the incoming request's query
432-
// string, then construct a new URL by replacing the S3 origin.
433-
// Next, we create a reverse proxy and configure it to pipe
434-
// response back to the original caller.
435-
//
436-
// The original S3 origin used when constructing the presigned
437-
// URL must match the proxied presigned URL.
438-
func ProxySymbol(c *gin.Context) {
439-
payload := c.Query("payload")
440-
if payload == "" {
441-
msg := `need payload for proxying to object store`
442-
c.JSON(http.StatusBadRequest, gin.H{
443-
"error": msg,
444-
})
445-
return
446-
}
447-
448-
config := server.Server.Config
449-
presignedUrl := payload
450-
451-
// if the payload already contains origin, then
452-
// don't prepend the origin.
453-
if !strings.HasPrefix(payload, config.AWSEndpoint) {
454-
presignedUrl = config.AWSEndpoint + payload
455-
}
456-
457-
parsed, err := url.Parse(presignedUrl)
458-
if err != nil {
459-
msg := "failed to parse reconstructed presigned url"
460-
fmt.Println(msg, err)
461-
c.JSON(http.StatusInternalServerError, gin.H{
462-
"error": msg,
463-
})
464-
return
465-
}
466-
467-
proxy := httputil.NewSingleHostReverseProxy(parsed)
468-
proxy.Director = func(req *http.Request) {
469-
req.URL.Scheme = parsed.Scheme
470-
req.URL.Host = parsed.Host
471-
req.URL.Path = parsed.Path
472-
req.URL.RawQuery = parsed.RawQuery
473-
req.Host = parsed.Host
474-
475-
req.Header = c.Request.Header
476-
}
477-
478-
proxy.ModifyResponse = func(resp *http.Response) error {
479-
if resp.StatusCode != http.StatusOK {
480-
fmt.Printf("Symbol proxy http status: %s\n", resp.Status)
481-
}
482-
return nil
483-
}
484-
485-
proxy.ServeHTTP(c.Writer, c.Request)
486-
}

0 commit comments

Comments
 (0)