Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WebServer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
codecraft
WebServer
Commits
61af39db
Commit
61af39db
authored
1 year ago
by
codecraft
Browse files
Options
Downloads
Patches
Plain Diff
Create the FromRequest trait
parent
f29d3004
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Initial feature merge
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/http/src/handlers/handlers.rs
+2
-2
2 additions, 2 deletions
core/http/src/handlers/handlers.rs
core/http/src/handling/request.rs
+21
-12
21 additions, 12 deletions
core/http/src/handling/request.rs
with
23 additions
and
14 deletions
core/http/src/handlers/handlers.rs
+
2
−
2
View file @
61af39db
...
...
@@ -10,7 +10,7 @@ use crate::handling::{
};
use
crate
::
setup
::
MountPoint
;
static
MAX_HTTPMESSAGE_SIZE
:
u16
=
4196
;
static
MAX_HTTP
_
MESSAGE_SIZE
:
u16
=
4196
;
pub
async
fn
handle_connection
(
mut
stream
:
TcpStream
,
mountpoints
:
Vec
<
MountPoint
<
'_
>>
)
{
let
mut
buf_reader
=
BufReader
::
new
(
&
mut
stream
);
...
...
@@ -88,7 +88,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
0
};
if
length
!=
0
{
let
mut
buffer
=
vec!
[
0u8
;
MAX_HTTPMESSAGE_SIZE
.into
()];
let
mut
buffer
=
vec!
[
0u8
;
MAX_HTTP
_
MESSAGE_SIZE
.into
()];
let
read
=
buf_reader
.read
(
&
mut
buffer
)
.await
.unwrap
();
if
read
!=
length
{
len_not_defined
(
stream
,
Status
::
LengthRequired
)
.await
;
...
...
This diff is collapsed.
Click to expand it.
core/http/src/handling/request.rs
+
21
−
12
View file @
61af39db
...
...
@@ -2,8 +2,6 @@
use
std
::{
collections
::
HashMap
,
error
::
Error
,
fmt
::
Display
};
use
tokio
::
io
::
BufReader
;
use
crate
::
utils
::
mime
::
mime_enum
::
Mime
;
static
TWO_NEWLINES
:
u8
=
3
;
...
...
@@ -13,7 +11,27 @@ use super::{
routes
::{
Data
,
Uri
},
};
pub
trait
FromRequest
:
Send
{
fn
get_data
(
&
self
)
->
&
Self
;
fn
set_data
(
&
mut
self
,
data
:
&
Self
);
fn
append
(
&
mut
self
,
data
:
&
Self
);
}
impl
FromRequest
for
Vec
<
u8
>
{
fn
get_data
(
&
self
)
->
&
Self
{
&
self
}
fn
set_data
(
&
mut
self
,
data
:
&
Self
)
{
*
self
=
data
.to_vec
();
}
fn
append
(
&
mut
self
,
data
:
&
Self
)
{
self
.extend_from_slice
(
data
);
}
}
type
HeaderMap
=
Vec
<
String
>
;
#[derive(Clone)]
pub
struct
Request
<
'a
>
{
pub
uri
:
Uri
<
'a
>
,
...
...
@@ -203,7 +221,7 @@ impl Request<'_> {
let
end_boundary
=
format!
(
"{temp_bound}--
\r
"
)
.as_bytes
()
.to_owned
();
temp_bound
.push
(
'\r'
);
let
boundary
=
temp_bound
.as_bytes
();
Request
::
get_multipart
(
data
,
boundary
,
&
end_boundary
,
&
mut
keymap
);
Request
::
get_multipart
_data
(
data
,
boundary
,
&
end_boundary
,
&
mut
keymap
);
}
_
=>
{
return
Err
(
ParseFormError
{
...
...
@@ -213,15 +231,6 @@ impl Request<'_> {
};
Ok
(
keymap
)
}
fn
decode_multipart
<
'a
>
(
data
:
&
Data
,
keys
:
&
[
&
'a
str
],
)
->
HashMap
<
String
,
Result
<
Vec
<
u8
>
,
ParseFormError
>>
{
let
mut
data
=
data
.buffer
.as_ref
();
let
mut
buf_reader
=
BufReader
::
new
(
&
mut
data
);
let
mut
http_request
:
Vec
<
String
>
=
Vec
::
with_capacity
(
2
);
todo!
()
}
fn
get_multipart_data
(
data
:
&
[
u8
],
boundary
:
&
[
u8
],
...
...
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