Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
10becd38
Commit
10becd38
authored
Aug 18, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor tweaks to web server.
parent
5db63685
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
webserver/webserver.go
webserver/webserver.go
+8
-7
No files found.
webserver/webserver.go
View file @
10becd38
...
@@ -117,6 +117,7 @@ func httpError(w http.ResponseWriter, err error) {
...
@@ -117,6 +117,7 @@ func httpError(w http.ResponseWriter, err error) {
http
.
Error
(
w
,
"403 forbidden"
,
http
.
StatusForbidden
)
http
.
Error
(
w
,
"403 forbidden"
,
http
.
StatusForbidden
)
return
return
}
}
log
.
Printf
(
"HTTP server error: %v"
,
err
)
http
.
Error
(
w
,
"500 Internal Server Error"
,
http
.
Error
(
w
,
"500 Internal Server Error"
,
http
.
StatusInternalServerError
)
http
.
StatusInternalServerError
)
return
return
...
@@ -200,6 +201,7 @@ func (fh *fileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
...
@@ -200,6 +201,7 @@ func (fh *fileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
index
:=
path
.
Join
(
p
,
"index.html"
)
index
:=
path
.
Join
(
p
,
"index.html"
)
ff
,
err
:=
fh
.
root
.
Open
(
index
)
ff
,
err
:=
fh
.
root
.
Open
(
index
)
if
err
!=
nil
{
if
err
!=
nil
{
// return 403 if index.html doesn't exist
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
err
=
os
.
ErrPermission
err
=
os
.
ErrPermission
}
}
...
@@ -253,7 +255,7 @@ func parseGroupName(prefix string, p string) string {
...
@@ -253,7 +255,7 @@ func parseGroupName(prefix string, p string) string {
return
""
return
""
}
}
name
:=
p
[
len
(
"/group/"
)
:
]
name
:=
p
[
len
(
prefix
)
:
]
if
name
==
""
{
if
name
==
""
{
return
""
return
""
}
}
...
@@ -280,8 +282,7 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -280,8 +282,7 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
}
}
if
r
.
URL
.
Path
!=
"/group/"
+
name
{
if
r
.
URL
.
Path
!=
"/group/"
+
name
{
http
.
Redirect
(
w
,
r
,
"/group/"
+
name
,
http
.
Redirect
(
w
,
r
,
"/group/"
+
name
,
http
.
StatusPermanentRedirect
)
http
.
StatusPermanentRedirect
)
return
return
}
}
...
@@ -298,8 +299,7 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -298,8 +299,7 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
}
}
if
redirect
:=
g
.
Redirect
();
redirect
!=
""
{
if
redirect
:=
g
.
Redirect
();
redirect
!=
""
{
http
.
Redirect
(
w
,
r
,
redirect
,
http
.
Redirect
(
w
,
r
,
redirect
,
http
.
StatusPermanentRedirect
)
http
.
StatusPermanentRedirect
)
return
return
}
}
...
@@ -414,13 +414,13 @@ func recordingsHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -414,13 +414,13 @@ func recordingsHandler(w http.ResponseWriter, r *http.Request) {
return
return
}
}
p
=
path
.
Clean
(
p
)
if
p
==
"/"
{
if
p
==
"/"
{
http
.
Error
(
w
,
"nothing to see"
,
http
.
StatusForbidden
)
http
.
Error
(
w
,
"nothing to see"
,
http
.
StatusForbidden
)
return
return
}
}
p
=
path
.
Clean
(
p
)
f
,
err
:=
os
.
Open
(
filepath
.
Join
(
diskwriter
.
Directory
,
p
))
f
,
err
:=
os
.
Open
(
filepath
.
Join
(
diskwriter
.
Directory
,
p
))
if
err
!=
nil
{
if
err
!=
nil
{
httpError
(
w
,
err
)
httpError
(
w
,
err
)
...
@@ -556,6 +556,7 @@ func checkGroupPermissions(w http.ResponseWriter, r *http.Request, groupname str
...
@@ -556,6 +556,7 @@ func checkGroupPermissions(w http.ResponseWriter, r *http.Request, groupname str
}
}
func
serveGroupRecordings
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
f
*
os
.
File
,
group
string
)
{
func
serveGroupRecordings
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
f
*
os
.
File
,
group
string
)
{
// read early, so we return permission errors to HEAD
fis
,
err
:=
f
.
Readdir
(
-
1
)
fis
,
err
:=
f
.
Readdir
(
-
1
)
if
err
!=
nil
{
if
err
!=
nil
{
http
.
Error
(
w
,
"server error"
,
http
.
StatusInternalServerError
)
http
.
Error
(
w
,
"server error"
,
http
.
StatusInternalServerError
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment