Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

The code should be in Java programming. Do not copy someone else's answer or I will complain about that. Thanks. Implement a multi-threaded HTTP server

image text in transcribed

The code should be in Java programming. Do not copy someone else's answer or I will complain about that. Thanks.

Implement a multi-threaded HTTP server that returns a document determined by the requested URI. Your server should be capable of providing concurrency via multi-threading. Your server program should take single argument which specifies the port number. Your server should retum an HTML document according to the requested URI. The size of the document is determined by the requested URI (any size between 100 and 20,000 bytes). Your server should remove the leading slash /" from the URI and extract the resulting string as an integer (in decimal) that specify the size of the document to be sent to the client. For example, if the request line is "GET /1500 HTTP/1.0", your server should send back an HTML file that contains exactly 1,500 bytes of text (When the client save the document on the local disk, the file size should be 1,500 bytes). The returned HTML file should have a proper HTML format with , and tags, but the content can be anything. If the requested URI asks for a size less than 100, or for a size greater than 20,000, or if the URL is not an integer, your server should not return any document, but instead it should return a "Bad Request" message with error code 400. If the method in request message is not GET, server would return "Not Implemented" (501) for valid HTTP methods other than GET, or "Bad Request" (400) for invalid methods. Your server must send back an HTTP response line, a Content-Type header and a ContentLength header. None of these count towards the size of the document. Your server should send back an HTTP response line that indicates an error if the requested URI is not a number, or is less than 100, or is greater than 20,000. Your server should print out information about every message received and every message sent. Your server should work when connected via a web browser (such as Internet Explorer or Google Chrome). For example, if the server port number is 8080, http://localhost:8080/500 would be a valid URL if the server runs in the same host.. Implement a multi-threaded HTTP server that returns a document determined by the requested URI. Your server should be capable of providing concurrency via multi-threading. Your server program should take single argument which specifies the port number. Your server should retum an HTML document according to the requested URI. The size of the document is determined by the requested URI (any size between 100 and 20,000 bytes). Your server should remove the leading slash /" from the URI and extract the resulting string as an integer (in decimal) that specify the size of the document to be sent to the client. For example, if the request line is "GET /1500 HTTP/1.0", your server should send back an HTML file that contains exactly 1,500 bytes of text (When the client save the document on the local disk, the file size should be 1,500 bytes). The returned HTML file should have a proper HTML format with , and tags, but the content can be anything. If the requested URI asks for a size less than 100, or for a size greater than 20,000, or if the URL is not an integer, your server should not return any document, but instead it should return a "Bad Request" message with error code 400. If the method in request message is not GET, server would return "Not Implemented" (501) for valid HTTP methods other than GET, or "Bad Request" (400) for invalid methods. Your server must send back an HTTP response line, a Content-Type header and a ContentLength header. None of these count towards the size of the document. Your server should send back an HTTP response line that indicates an error if the requested URI is not a number, or is less than 100, or is greater than 20,000. Your server should print out information about every message received and every message sent. Your server should work when connected via a web browser (such as Internet Explorer or Google Chrome). For example, if the server port number is 8080, http://localhost:8080/500 would be a valid URL if the server runs in the same host

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

ISBN: 0262660709, 978-0262660709

More Books

Students explore these related Databases questions

Question

b. Where did they come from?

Answered: 3 weeks ago