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
31f29ad0
Commit
31f29ad0
authored
1 year ago
by
codecraft
Browse files
Options
Downloads
Patches
Plain Diff
Start working on cookies
parent
94944f32
No related branches found
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
+4
-1
4 additions, 1 deletion
core/http/src/handlers/handlers.rs
core/http/src/handling/request.rs
+3
-0
3 additions, 0 deletions
core/http/src/handling/request.rs
with
7 additions
and
1 deletion
core/http/src/handlers/handlers.rs
+
4
−
1
View file @
31f29ad0
...
@@ -26,6 +26,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
...
@@ -26,6 +26,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
}
}
http_request
.push
(
buffer
);
http_request
.push
(
buffer
);
}
}
println!
(
"{:?}"
,
http_request
);
let
request_status_line
=
if
let
Some
(
status_line
)
=
http_request
.get
(
0
)
.cloned
()
{
let
request_status_line
=
if
let
Some
(
status_line
)
=
http_request
.get
(
0
)
.cloned
()
{
status_line
status_line
...
@@ -33,6 +34,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
...
@@ -33,6 +34,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
eprintln!
(
"
\x1b
[31mAborting due to missing headers
\x1b
[0m"
);
eprintln!
(
"
\x1b
[31mAborting due to missing headers
\x1b
[0m"
);
return
;
return
;
};
};
let
request
=
Request
{
let
request
=
Request
{
uri
:
if
let
Some
(
uri
)
=
&
request_status_line
.split
(
" "
)
.nth
(
1
)
{
uri
:
if
let
Some
(
uri
)
=
&
request_status_line
.split
(
" "
)
.nth
(
1
)
{
*
uri
*
uri
...
@@ -40,6 +42,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
...
@@ -40,6 +42,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
eprintln!
(
"
\x1b
[31mAborting due to invalid status line
\x1b
[0m"
);
eprintln!
(
"
\x1b
[31mAborting due to invalid status line
\x1b
[0m"
);
return
;
return
;
},
},
cookies
:
None
,
headers
:
http_request
,
headers
:
http_request
,
method
:
if
let
Some
(
method
)
=
request_status_line
method
:
if
let
Some
(
method
)
=
request_status_line
.split
(
" "
)
.split
(
" "
)
...
@@ -53,7 +56,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
...
@@ -53,7 +56,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
}
else
{
}
else
{
eprintln!
(
"
\x1b
[31mAborting due to invalid status line
\x1b
[0m"
);
eprintln!
(
"
\x1b
[31mAborting due to invalid status line
\x1b
[0m"
);
return
;
return
;
}
}
,
};
};
let
mut
data
=
Data
{
let
mut
data
=
Data
{
...
...
This diff is collapsed.
Click to expand it.
core/http/src/handling/request.rs
+
3
−
0
View file @
31f29ad0
...
@@ -37,6 +37,7 @@ pub struct Request<'a> {
...
@@ -37,6 +37,7 @@ pub struct Request<'a> {
pub
uri
:
Uri
<
'a
>
,
pub
uri
:
Uri
<
'a
>
,
pub
headers
:
HeaderMap
,
pub
headers
:
HeaderMap
,
pub
method
:
Method
,
pub
method
:
Method
,
pub
cookies
:
Option
<
Vec
<&
'a
str
>>
,
// pub connection: ConnectionMeta,
// pub connection: ConnectionMeta,
}
}
...
@@ -316,6 +317,7 @@ mod test {
...
@@ -316,6 +317,7 @@ mod test {
uri
:
""
,
uri
:
""
,
headers
:
vec!
[
"Content-Type: application/x-www-form-urlencoded"
.to_string
()],
headers
:
vec!
[
"Content-Type: application/x-www-form-urlencoded"
.to_string
()],
method
:
crate
::
handling
::
methods
::
Method
::
Post
,
method
:
crate
::
handling
::
methods
::
Method
::
Post
,
cookies
:
None
,
};
};
let
data
=
Data
{
let
data
=
Data
{
buffer
:
b"message=23&message1=24"
.to_vec
(),
buffer
:
b"message=23&message1=24"
.to_vec
(),
...
@@ -334,6 +336,7 @@ mod test {
...
@@ -334,6 +336,7 @@ mod test {
uri
:
""
,
uri
:
""
,
headers
:
vec!
[
"Content-Type: multipart/form-data; boundary=
\"
boundary
\"
"
.to_string
()],
headers
:
vec!
[
"Content-Type: multipart/form-data; boundary=
\"
boundary
\"
"
.to_string
()],
method
:
crate
::
handling
::
methods
::
Method
::
Post
,
method
:
crate
::
handling
::
methods
::
Method
::
Post
,
cookies
:
None
,
};
};
let
data
=
Data
{
let
data
=
Data
{
buffer
:
b"--boundary
\r
buffer
:
b"--boundary
\r
...
...
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