logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Use the Cleansocks interface to create a simple web client that takes a single URL on the command line.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Use the Cleansocks interface to create a simple web client that takes a single URL on the command line. It should report the server's IP address, the response code, server type, value of the location header (if present), and and any cookies set by the server. If the server forwards the request, the client should follow. You might want to start with the posted URL downloader example. The output looks like this:

[tom@localhost asst]$ headinfo

http://sandbox.mc.edu/-bennet/cs423v2/syl.html

Server at 167.160.210.32 responds 200 OK

Server type: type Apache/2.4.51 (Fedora) OpenSSL/1.1.11.

No cookies were set.

[tom@localhost asst]$ headinfo https://www.google.com

Server at 172.217.10.196 responds 200 OK

Server type: type gws.

Cookies:

1P_JAR: 2022-01-20-03

NID: 511=W_571e5ZrEAJO FLpehjgFtbYONh8XPk8YKzjn_5v7VaMrtCSA2Q1W9 LadnIoP9Eon7QeeFycYfCQ0Hoxx300DYDULdwgJ6ifuQP7zzFcbdqDC6HyhzihtwjVlqlQESA0ArLucQe [tom@localhost asst]$ headinfo http://www.parliament.uk/visiting/visiting-and-tours/tours-of-parliament/guided-tours-of-parliament/ Server at 104.17.150.48 responds 403 Forbidden

Server type: type cloudflare. Cookies:

_cf_bm: FRQCRi8q8.NH5j.U8mHxhjz8LOIKhccdh2aPbFvf._o-1642649818-0-AYJHkiowhgM5UhkITlaBYOXaBjLxFgw/w8lrEVBARN3CPQvz318ajhxoskYL3XpD1113D8tppa9Ng3M Your application must extract the host name and path from the URL and send an HTTP HEAD request to the indicated machine. Parse the response line and headers to get the information you need to report. The relevant header names are Server, Location and Set-Cookie. The Server will appear once or not at all. If it does not appear, just say that the server type is "Unknown". The Location header may appear once, but usually not at all. If not present, simply don't mention it in your output. A server may set no cookies, or it may set more than one, so the Set-Cookie header may appear any number of times. If it does not appear, state that no cookies were set, otherwise list them all. You should list the name and value for each one (see below).

If some networking error prevents the reception of any response from the server, or the server's response cannot be parsed as an HTTP response, print an appropriate error message. Otherwise, give the numeric response code and message from the response (even if it is an error), then print the type of server, and list any cookies set by the server. Network errors are thrown as exceptions by cleansocks, so you will need to catch them and print the value of the exception's . what () method.

[tom@tomslap asst ]$ headinfo http://www.forgetit.calm

Error: [IPaddress::lookup (www.forget it. calm)] Name or service not known

You need only consider very simple URLs. Accept only http or https URLs, and don't look for port number or passwords. If the URL is not simple or can't be parsed, just report an error and exit.

The value of the setCookie header is a string which gives the name and value of the cookie. The form is something like this:

SetCookie: name=value; other stuff

Where the other stuff may or may not be present. (The standard calls this part "unparsed attributes," even though the client must parse it. We'll discard it.) If you find a ; in the cookie string, discard the (first); and everything after it. If you don't find an =, then the cookie is invalid, and you should discard the whole thing. Otherwise, the name of the cookie is the portion of the string up to the first =, and the value is the portion after the first =. "First" is important here, because the value may contain additional equal signs. (Google seems to love these.) The standard says that either the name or value is allowed to be empty, but I don't know that I've seen this actually happen.

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

890 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

504 Answers

Hire Me
expert
Husnain SaeedComputer science

755 Answers

Hire Me
expert
Atharva PatilComputer science

821 Answers

Hire Me

Get Free Quote!

416 Experts Online