Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Simple Http Server
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Simple Http Server
Commits
9514f99c
There was an error fetching the commit references. Please try again later.
Unverified
Commit
9514f99c
authored
1 year ago
by
Linfeng Qian
Browse files
Options
Downloads
Patches
Plain Diff
cargo update and fix clippy
parent
9b3871c1
No related branches found
No related tags found
No related merge requests found
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
Cargo.lock
+302
-201
302 additions, 201 deletions
Cargo.lock
rust-toolchain
+1
-1
1 addition, 1 deletion
rust-toolchain
src/main.rs
+8
-8
8 additions, 8 deletions
src/main.rs
src/middlewares/compress.rs
+2
-2
2 additions, 2 deletions
src/middlewares/compress.rs
src/util.rs
+2
-2
2 additions, 2 deletions
src/util.rs
with
315 additions
and
214 deletions
Cargo.lock
+
302
−
201
View file @
9514f99c
This diff is collapsed.
Click to expand it.
rust-toolchain
+
1
−
1
View file @
9514f99c
1.61.0
stable
This diff is collapsed.
Click to expand it.
src/main.rs
+
8
−
8
View file @
9514f99c
...
...
@@ -842,8 +842,8 @@ impl MainHandler {
resp
.headers
.set
(
headers
::
ContentType
::
html
());
if
self
.compress
.is_some
()
{
if
let
Some
(
&
AcceptEncoding
(
ref
encodings
))
=
req
.headers.get
::
<
AcceptEncoding
>
()
{
for
&
QualityItem
{
ref
item
,
..
}
in
encodings
{
if
let
Some
(
AcceptEncoding
(
encodings
))
=
req
.headers.get
::
<
AcceptEncoding
>
()
{
for
QualityItem
{
item
,
..
}
in
encodings
{
if
*
item
==
Encoding
::
Deflate
||
*
item
==
Encoding
::
Gzip
{
resp
.headers
.set
(
ContentEncoding
(
vec!
[
item
.clone
()]));
}
...
...
@@ -914,7 +914,7 @@ impl MainHandler {
if
range
.is_some
()
{
// [Reference]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match
// Check header::If-Match
if
let
Some
(
&
IfMatch
::
Items
(
ref
items
))
=
req
.headers.get
::
<
IfMatch
>
()
{
if
let
Some
(
IfMatch
::
Items
(
items
))
=
req
.headers.get
::
<
IfMatch
>
()
{
if
!
items
.iter
()
.any
(|
item
|
item
.strong_eq
(
&
etag
))
{
return
Err
(
IronError
::
new
(
StringError
(
"Etag not matched"
.to_owned
()),
...
...
@@ -926,8 +926,8 @@ impl MainHandler {
// [Reference]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Range
let
matched_ifrange
=
match
req
.headers.get
::
<
IfRange
>
()
{
Some
(
&
IfRange
::
EntityTag
(
ref
etag_ifrange
))
=>
etag
.weak_eq
(
etag_ifrange
),
Some
(
&
IfRange
::
Date
(
HttpDate
(
ref
date_ifrange
)))
=>
{
Some
(
IfRange
::
EntityTag
(
etag_ifrange
))
=>
etag
.weak_eq
(
etag_ifrange
),
Some
(
IfRange
::
Date
(
HttpDate
(
date_ifrange
)))
=>
{
time
::
at
(
modified
)
<=
*
date_ifrange
}
None
=>
true
,
...
...
@@ -937,7 +937,7 @@ impl MainHandler {
}
match
range
{
Some
(
&
Range
::
Bytes
(
ref
ranges
))
=>
{
Some
(
Range
::
Bytes
(
ranges
))
=>
{
if
let
Some
(
range
)
=
ranges
.get
(
0
)
{
let
(
offset
,
length
)
=
match
*
range
{
ByteRangeSpec
::
FromTo
(
x
,
mut
y
)
=>
{
...
...
@@ -1022,8 +1022,8 @@ impl MainHandler {
if
resp
.status
!=
Some
(
status
::
PartialContent
)
&&
exts
.iter
()
.any
(|
ext
|
path_str
.ends_with
(
ext
))
{
if
let
Some
(
&
AcceptEncoding
(
ref
encodings
))
=
req
.headers.get
::
<
AcceptEncoding
>
()
{
for
&
QualityItem
{
ref
item
,
..
}
in
encodings
{
if
let
Some
(
AcceptEncoding
(
encodings
))
=
req
.headers.get
::
<
AcceptEncoding
>
()
{
for
QualityItem
{
item
,
..
}
in
encodings
{
if
*
item
==
Encoding
::
Deflate
||
*
item
==
Encoding
::
Gzip
{
resp
.headers
.set
(
ContentEncoding
(
vec!
[
item
.clone
()]));
break
;
...
...
This diff is collapsed.
Click to expand it.
src/middlewares/compress.rs
+
2
−
2
View file @
9514f99c
...
...
@@ -40,14 +40,14 @@ impl AfterMiddleware for CompressionHandler {
}
let
mut
encoding
:
Option
<
Encoding
>
=
None
;
if
let
Some
(
&
ContentEncoding
(
ref
objs
))
=
resp
.headers.get
::
<
ContentEncoding
>
()
{
if
let
Some
(
ContentEncoding
(
objs
))
=
resp
.headers.get
::
<
ContentEncoding
>
()
{
encoding
=
objs
.iter
()
.find
(|
obj
|
*
obj
==
&
Encoding
::
Deflate
||
*
obj
==
&
Encoding
::
Gzip
)
.cloned
();
}
if
encoding
.is_none
()
{
if
let
Some
(
&
TransferEncoding
(
ref
objs
))
=
resp
.headers.get
::
<
TransferEncoding
>
()
{
if
let
Some
(
TransferEncoding
(
objs
))
=
resp
.headers.get
::
<
TransferEncoding
>
()
{
encoding
=
objs
.iter
()
.find
(|
obj
|
*
obj
==
&
Encoding
::
Deflate
||
*
obj
==
&
Encoding
::
Gzip
)
...
...
This diff is collapsed.
Click to expand it.
src/util.rs
+
2
−
2
View file @
9514f99c
...
...
@@ -42,7 +42,7 @@ impl Deref for StringError {
type
Target
=
str
;
fn
deref
(
&
self
)
->
&
Self
::
Target
{
&
*
self
.0
&
self
.0
}
}
...
...
@@ -133,7 +133,7 @@ pub fn system_time_to_date_time(t: SystemTime) -> DateTime<Local> {
}
}
};
Local
.timestamp
(
sec
,
nsec
)
Local
.timestamp
_opt
(
sec
,
nsec
)
.unwrap
()
}
pub
fn
error_resp
(
s
:
status
::
Status
,
msg
:
&
str
)
->
Response
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment