-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_cases.txt
268 lines (207 loc) · 6.75 KB
/
test_cases.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
1. Print help menu
./main -h or ./main --help
Help commands
-h --help: print this help
-d : Debug mode on
-H : print out <HEAD> </HEAD> only
-B -b: print out <BODY> </BODY> only
-O -o: print out HTTP response only ( no html )
Example:
./main http://info.cern.ch/hypertext/WWW/TheProject.html: Send request to info.cern.ch
./main -H hhttp://info.cern.ch/hypertext/WWW/TheProject.html: Send request to info.cern.ch return html between <HEADER> </HEADER> only
./main -d -H hhttp://info.cern.ch/hypertext/WWW/TheProject.html: Send request to info.cern.ch return html between <HEADER> </HEADER> only with debug mode on
./main -B hhttp://info.cern.ch/hypertext/WWW/TheProject.html: Send request to info.cern.ch return html between <BODY> </BODY> only
2. Successfully send request to http://www.doublepup.com/ip.txt
./main -d http://www.doublepup.com/ip.txt
Output:
Protocol: http
Site: www.doublepup.com
path: ip.txt
The IP address of doublepup.com is 216.92.194.126
HTTP/1.1 200 OK
Date: Sat, 10 Dec 2022 12:28:02 GMT
Server: Apache
Last-Modified: Tue, 23 Aug 2016 04:32:26 GMT
ETag: "f-53ab5a6dfd00d"
Accept-Ranges: bytes
Content-Length: 15
Content-Type: text/plain
216.92.194.126
Response code: 200
OK
3. Only HTTP is valid
./main https://www.doublepup.com
ERROR: Invalid protocol. Only HTTP is supported
4. Send request to non-exist host
./main http://localhost:5173
ERROR: Could not resolve host
5. Successfully print out html from the website
./main http://info.cern.ch/hypertext/WWW/TheProject.html
<HEADER>
<TITLE>The World Wide Web project</TITLE>
<NEXTID N="55">
</HEADER>
<BODY>
<H1>World Wide Web</H1>The WorldWideWeb (W3) is a wide-area<A
NAME=0 HREF="WhatIs.html">
hypermedia</A> information retrieval
initiative aiming to give universal
access to a large universe of documents.<P>
Everything there is online about
W3 is linked directly or indirectly
to this document, including an <A
NAME=24 HREF="Summary.html">executive
summary</A> of the project, <A
NAME=29 HREF="Administration/Mailing/Overview.html">Mailing lists</A>
, <A
NAME=30 HREF="Policy.html">Policy</A> , November's <A
NAME=34 HREF="News/9211.html">W3 news</A> ,
<A
NAME=41 HREF="FAQ/List.html">Frequently Asked Questions</A> .
<DL>
<DT><A
NAME=44 HREF="../DataSources/Top.html">What's out there?</A>
<DD> Pointers toGET /hypertext/WWW/TheProject.html HTTP/1.1
Host: info.cern.ch
Accept: text/plain, text/html, application/json, application/xml
6. Redirect when response code 3xx
./main http://inst.eecs.berkeley.edu/~cs280/sp18/
https://inst.eecs.berkeley.edu/~cs280/sp18/
7. print only <HEADER> </HEADER> if -H args
./main -H http://info.cern.ch/hypertext/Conferences/Overview.html
<TITLE>Conferences in hypertext, networking and IR</TITLE>
<NEXTID N="25">
8. Print only <BODY> </BODY> if -b or -B args
./main -B http://info.cern.ch/hypertext/Conferences/Overview.html
<H1>Conferences</H1>This is a list of conferences relevant
to hypertext and networking. Reverse
chronological order.
<DL>
<DT>NSC93
<DD>Network Services Conference,
112-14 October 1993, Warsaw, Poland.
<DD>
<DT><A
NAME=24 HREF="INET93/CFP.html">INET93</A>
<DD> Internet Society's anual conference.
San Francisco. 17-20 August 93.
<DT>IETF 27
<DD>Amsterdam, Netherlands. July.
<DT>JENC4
<DD>Fourth Joint Networking Conference,
Trondheim, Norway. 10-13 May 1993
<DT>IETF 26
<DD>Columbus Ohio, USA, March
28 - April 2.
<DT>NORDUNET 93
<DD>15-17 Feb 93, Helsinki,
Finland.
</DL>
<H2>1992</H2>
<DL>
<DT><A
NAME=21 HREF="NSC92/CallForParticpation.html">NSC92</A>
<DD> Networks Services ConferencGET /hypertext/Conferences/Overview.html HTTP/1.1
Host: info.cern.ch
Accept: text/plain, text/html, application/json, application/xml
8. Print HTTP RESPONSE ONLY if -o or -O args
./main -o http://info.cern.ch/hypertext/Conferences/Overview.html
HTTP/1.1 200 OK
Date: Wed, 07 Dec 2022 12:25:24 GMT
Server: Apache
Last-Modified: Tue, 01 Dec 1992 16:07:31 GMT
ETag: "838-291c52fdcb6c0"
Accept-Ranges: bytes
Content-Length: 2104
Connection: close
Content-Type: text/htmlOK
9. Empty protocol -> protocol = "http"
./main -d info.cern.ch/hypertext/WWW/TheProject.html
Protocol: http
Site: info.cern.ch
path: hypertext/WWW/TheProject.html
The IP address of webafs706.cern.ch is 188.184.21.108
HTTP/1.1 200 OK
Date: Sat, 10 Dec 2022 12:27:08 GMT
Server: Apache
Last-Modified: Thu, 03 Dec 1992 08:37:20 GMT
ETag: "8a9-291e721905000"
Accept-Ranges: bytes
Content-Length: 2217
Connection: close
Content-Type: text/html
<HEADER>
<TITLE>The World Wide Web project</TITLE>
<NEXTID N="55">
</HEADER>
<BODY>
<H1>World Wide Web</H1>The WorldWideWeb (W3) is a wide-area<A
NAME=0 HREF="WhatIs.html">
hypermedia</A> information retrieval
initiative aiming to give universal
access to a large universe of documents.<P>
Everything there is online about
W3 is linked directly or indirectly
to this document, including an <A
NAME=24 HREF="Summary.html">executive
summary</A> of the project, <A
NAME=29 HREF="Administration/Mailing/Overview.html">Mailing lists</A>
, <A
NAME=30 HREF="Policy.html">Policy</A> , November's <A
NAME=34 HREF="News/9211.html">W3 news</A> ,
<A
NAME=41 HREF="FAQ/List.html">Frequently Asked Questions</A> .
<DL>
<DT><A
NAME=44 HREF="../DataSources/Top.html">What's out there?</A>
<DD> Pointers toGET /hypertext/WWW/TheProject.html HTTP/1.1
Host: info.cern.ch
Accept: text/plain, text/html, application/json, application/xml
Response code: 200
OK
10. Empty path -> path = "/"
./main -d http://info.cern.ch/
Protocol: http
Site: info.cern.ch
path: /
Host IP: 188.184.21.108
HTTP/1.1 200 OK
Date: Sat, 10 Dec 2022 00:33:22 GMT
Server: Apache
Last-Modified: Wed, 05 Feb 2014 16:00:31 GMT
ETag: "286-4f1aadb3105c0"
Accept-Ranges: bytes
Content-Length: 646
Connection: close
Content-Type: text/html
<html><head></head><body><header>
<title>http://info.cern.ch</title>
</header>
<h1>http://info.cern.ch - home of the first website</h1>
<p>From here you can:</p>
<ul>
<li><a href="http://info.cern.ch/hypertext/WWW/TheProject.html">Browse the first website</a></li>
<li><a href="http://line-mode.cern.ch/www/hypertext/WWW/TheProject.html">Browse the first website using the line-mode browser simulator</a></li>
<li><a href="http://home.web.cern.ch/topics/birth-web">Learn about the birth of the web</a></li>
<li><a href="http://home.web.cern.ch/about">Learn about CERN, the physics laboratory where the web was born</a></li>
</ul>
</body></html>
Response code: 200
OK
11. Input is ip address
./main -d http://216.92.194.126/ip.txt
Protocol: http
Site: 216.92.194.126
path: ip.txt
The IP address of 216.92.194.126 is 216.92.194.126
HTTP/1.1 200 OK
Date: Sat, 10 Dec 2022 12:25:59 GMT
Server: Apache
Last-Modified: Tue, 23 Aug 2016 04:32:26 GMT
ETag: "f-53ab5a6dfd00d"
Accept-Ranges: bytes
Content-Length: 15
Content-Type: text/plain
216.92.194.126
Response code: 200
OK