Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
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
Xun Zhang
comp30023-2019-project-1
Commits
942cb5c2
Commit
942cb5c2
authored
Apr 29, 2019
by
ChouTatsumi
Browse files
Options
Downloads
Patches
Plain Diff
start method test 20:30
parent
9fdb3b5b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
server.c
+1
-1
1 addition, 1 deletion
server.c
test.c
+46
-0
46 additions, 0 deletions
test.c
testresult
+0
-95
0 additions, 95 deletions
testresult
with
47 additions
and
96 deletions
server.c
+
1
−
1
View file @
942cb5c2
...
@@ -384,7 +384,7 @@ bool show_start_page(int sockfd, char* username) {
...
@@ -384,7 +384,7 @@ bool show_start_page(int sockfd, char* username) {
// the length needs to include the html tags for the username
// the length needs to include the html tags for the username
long
added_length
=
username_length
+
9
;
long
added_length
=
username_length
+
9
;
char
added
[
2048
];
char
added
[
added_length
];
// create added string
// create added string
strncpy
(
added
,
added_prefix
,
added_prefix_length
);
strncpy
(
added
,
added_prefix
,
added_prefix_length
);
...
...
This diff is collapsed.
Click to expand it.
test.c
0 → 100644
+
46
−
0
View file @
942cb5c2
else
if
(
strstr
(
buff
,
"user="
)
!=
NULL
)
{
// locate the username, it is safe to do so in this sample code, but usually
// the result is expected to be
// copied to another buffer using strcpy or strncpy to ensure that it will
// not be overwritten.
char
*
username
=
strstr
(
buff
,
"user="
)
+
5
;
int
username_length
=
strlen
(
username
);
// the length needs to include the ", " before the username
long
added_length
=
username_length
+
9
;
// get the size of the file
struct
stat
st
;
stat
(
"2_start.html"
,
&
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
)
{
perror
(
"write"
);
return
false
;
}
// read the content of the HTML file
int
filefd
=
open
(
"2_start.html"
,
O_RDONLY
);
n
=
read
(
filefd
,
buff
,
2048
);
if
(
n
<
0
)
{
perror
(
"read"
);
close
(
filefd
);
return
false
;
}
close
(
filefd
);
// printf("let me see what in the file\n");
// move the trailing part backward
int
p1
,
p2
;
for
(
p1
=
size
-
1
,
p2
=
p1
-
added_length
;
p1
>=
size
-
212
;
--
p1
,
--
p2
)
buff
[
p1
]
=
buff
[
p2
];
// copy the username
char
*
buf
=
"<p>"
;
int
buf_length
=
strlen
(
buf
);
strncpy
(
buff
+
p2
,
buf
,
buf_length
);
strncpy
(
buff
+
p2
+
buf_length
,
username
,
username_length
);
char
*
endbuf
=
"</p >
\n\n
"
;
int
endbuf_length
=
strlen
(
endbuf
);
strncpy
(
buff
+
p2
+
buf_length
+
username_length
,
endbuf
,
endbuf_length
);
buff
[
p2
+
buf_length
+
username_length
+
endbuf_length
]
=
'<'
;
/*
for
(
int
i
\ No newline at end of file
This diff is collapsed.
Click to expand it.
testresult
deleted
100644 → 0
+
0
−
95
View file @
9fdb3b5b
xunz4@None:~/comp30023/comp30023-2019-project-1$ ./image_tagger 172.26.37.133 8000
image_tagger server is now running at IP: 172.26.37.133 on port 8000
new connection from 10.9.131.233 on socket 4
New request from 4
GET / HTTP/1.1
Host: 172.26.37.133:8000
Connection: keep-alive
Purpose: prefetch
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
END
new connection from 10.9.131.233 on socket 5
socket 5 close the connection
New request from 4
POST / HTTP/1.1
Host: 172.26.37.133:8000
Connection: keep-alive
Content-Length: 9
Cache-Control: max-age=0
Origin: http://172.26.37.133:8000
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Referer: http://172.26.37.133:8000/
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
user=test
END
new connection from 10.9.131.233 on socket 5
new connection from 10.9.131.233 on socket 6
New request from 6
GET / HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134
Accept-Language: zh-Hans-CN,zh-Hans;q=0.8,ja;q=0.6,en-AU;q=0.4,en;q=0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Upgrade-Insecure-Requests: 1
Accept-Encoding: gzip, deflate
Host: 172.26.37.133:8000
Connection: Keep-Alive
END
socket 5 close the connection
New request from 6
POST / HTTP/1.1
Referer: http://172.26.37.133:8000/
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134
Accept-Language: zh-Hans-CN,zh-Hans;q=0.8,ja;q=0.6,en-AU;q=0.4,en;q=0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Upgrade-Insecure-Requests: 1
Accept-Encoding: gzip, deflate
Host: 172.26.37.133:8000
Content-Length: 9
Connection: Keep-Alive
user=user
END
New request from 6
GET /?start=Start HTTP/1.1
Referer: http://172.26.37.133:8000/
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134
Accept-Language: zh-Hans-CN,zh-Hans;q=0.8,ja;q=0.6,en-AU;q=0.4,en;q=0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Upgrade-Insecure-Requests: 1
Accept-Encoding: gzip, deflate
Host: 172.26.37.133:8000
Connection: Keep-Alive
END
New request from 4
GET /?start=Start HTTP/1.1
Host: 172.26.37.133:8000
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Referer: http://172.26.37.133:8000/
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
END
new connection from 10.9.131.233 on socket 5
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