Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tdenning_comp30023_2019_project-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Terence Denning
tdenning_comp30023_2019_project-1
Commits
e473bd92
Commit
e473bd92
authored
Apr 17, 2019
by
Terence Denning
Browse files
Options
Downloads
Patches
Plain Diff
update
parent
87b3e5e9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
http-server.c
+11
-4
11 additions, 4 deletions
http-server.c
server
+0
-0
0 additions, 0 deletions
server
with
11 additions
and
4 deletions
http-server.c
+
11
−
4
View file @
e473bd92
...
...
@@ -36,6 +36,7 @@ static int const HTTP_404_LENGTH = 45;
static
int
user1
=
-
1
;
static
int
user1_start
=
0
;
static
int
user2
=
-
1
;
static
int
user2_start
=
0
;
...
...
@@ -91,14 +92,18 @@ static bool handle_http_request(int sockfd)
while
(
*
curr
==
'.'
||
*
curr
==
'/'
){
++
curr
;
}
printf
(
"I AM THE CURRENT: %s
\n\n\n
"
,
curr
);
// assume the only valid request URI is "/" but it can be modified to accept more files
if
(
*
curr
==
' '
)
{
if
(
strlen
(
curr
)
>
0
)
{
if
(
method
==
GET
)
{
if
(
strstr
(
buff
,
"?start=Start"
)
!=
NULL
){
if
(
sockfd
==
user1
){
user1_start
=
1
;
}
else
if
(
sockfd
==
user2
){
user2_start
=
1
;
}
webpage
=
"html/3_first_turn.html"
;
printf
(
"
\n\n\n
WORKING
\n\n\n
"
);
}
else
{
webpage
=
"html/1_intro.html"
;
}
...
...
@@ -150,9 +155,11 @@ static bool handle_http_request(int sockfd)
// get the size of the file
struct
stat
st
;
stat
(
webpage
,
&
st
);
// increase file size to accommodate the username
long
size
=
st
.
st_size
+
added_length
;
n
=
sprintf
(
buff
,
HTTP_200_FORMAT
,
size
);
// send the header first
if
(
write
(
sockfd
,
buff
,
n
)
<
0
)
{
...
...
This diff is collapsed.
Click to expand it.
server
+
0
−
0
View file @
e473bd92
No preview for this file type
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