MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / proxy

Function proxy

server/handles/down.go:95–126  ·  view source on GitHub ↗
(c *gin.Context, link *model.Link, file model.Obj, proxyRange bool)

Source from the content-addressed store, hash-verified

93}
94
95func proxy(c *gin.Context, link *model.Link, file model.Obj, proxyRange bool) {
96 defer link.Close()
97 var err error
98 if link.URL != "" && setting.GetBool(conf.ForwardDirectLinkParams) {
99 query := c.Request.URL.Query()
100 for _, v := range conf.SlicesMap[conf.IgnoreDirectLinkParams] {
101 query.Del(v)
102 }
103 link.URL, err = utils.InjectQuery(link.URL, query)
104 if err != nil {
105 common.ErrorPage(c, err, 500)
106 return
107 }
108 }
109 if proxyRange {
110 link = common.ProxyRange(c, link, file.GetSize())
111 }
112 Writer := &common.WrittenResponseWriter{ResponseWriter: c.Writer}
113 err = common.Proxy(Writer, c.Request, link, file)
114 if err == nil {
115 return
116 }
117 if Writer.IsWritten() {
118 log.Errorf("%s %s local proxy error: %+v", c.Request.Method, c.Request.URL.Path, err)
119 } else {
120 if statusCode, ok := errs.UnwrapOrSelf(err).(net.HttpStatusCodeError); ok {
121 common.ErrorPage(c, err, int(statusCode), true)
122 } else {
123 common.ErrorPage(c, err, 500, true)
124 }
125 }
126}
127
128// TODO need optimize
129// when can be proxy?

Callers 4

ArchiveProxyFunction · 0.85
SharingDownFunction · 0.85
SharingArchiveExtractFunction · 0.85
ProxyFunction · 0.85

Calls 10

IsWrittenMethod · 0.95
GetBoolFunction · 0.92
InjectQueryFunction · 0.92
ErrorPageFunction · 0.92
ProxyRangeFunction · 0.92
ProxyFunction · 0.92
UnwrapOrSelfFunction · 0.92
CloseMethod · 0.65
DelMethod · 0.65
GetSizeMethod · 0.65

Tested by

no test coverage detected