EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

EG1hao
网课代修代上,cs代写代考
热门代写
您的位置: 主页 > 写作技巧 > 热门代写 >
network programming代写 C++代写
发布时间:2021-03-05 20:43:25浏览次数:
Figure 1: A layered architecture of the server。 You need to implement the three components highlighted with bold fonts。
network programming代写,C++/C代写

value store is to be implemented under two different path prefixes。 Figure 1 shows the overall architecture of the web server。
The HTTP-like Protocol
The basic mechanism of this HTTP-like protocol is the same as that of HTTP 1。1。 That is, when the server accepts a new TCP connection from a client, it reads the request headers and an optional request body sent by the client, and then sends valid response headers and optionally a response body。 After such a request-response cycle, the connection is persisted (not closing immediately), and the server waits for a new request from the client or a notification for closing the connection。network programming代写
For the simple scenarios in this assignment, the server only needs to handle the basic request and response information along with the “Content-Length” header field。 Therefore,
we simplify the header format of this protocol from that of the actual HTTP 1。1 as follows:
All new-line (i。e。 “\r\n”) and colon delimiters are replaced by single-space delimiters, as we do not have header components that contain spaces。 Here, space is defined as the character with ASCII code 32。 This means that the header is now a string consisting of non-empty substrings concatenated with a space in between, and that two consecutive spaces mark the end of header。 The header string should contain only ASCII
Each header field consists of two substrings。 The first is the case-insensitive name of the header field, and the second is the value of this
For a request, the first two substrings are the case-insensitive HTTP method followed by the case-sensitive path。 If there is a content body after the header, a “Content-Length” network programming代写 headerand its value follow the first two  Finally, the header is ended with two consecutive spaces。 For example, the entire request could be
a。GET␣/file/cs2105。txt␣␣
b。GET␣/file/CS2105。txt␣␣
c。POST␣/key/ModuleCode␣Content-Length␣6␣␣CS2105
Here, space is denoted by ␣ and content body is denoted by bold fonts。
Fora  The first two substrings are the HTTP status code followed by a non-empty description of the status。 The description has no real effects and is kept as a convention as in HTTP。 If the response has a content body, a “Content-Length” header should similarly be included。 Corresponding to the three sample requests above, the responses could be
a。404␣NotFound␣␣
b。200␣OK␣content-length␣27␣␣Intro␣To␣Computer␣Networks!network programming代写
c。200␣Okay␣␣
The server can assume that the client only sends correctly formatted requests。 The client may send unknown headers which the server should ignore。
The Key-value Store
A key-value store can be understood as a dictionary data structure that supports insertion, update, retrieval, and deletion of key-value pairs, with keys functioning as pointers to the values。 In this assignment, we restrict keys to be case-sensitive strings for simplicity。 Due to the use of “Content-Length” header, values can safely be any binary string。 The server should keep all data in memory only and avoid accessing the disk。network programming代写
The key-value store should be accessible to the client through paths with prefix “/key/”。 To operate on a specific key, the complete HTTP path is “/key/” appended with the actual key string。 For example, a request to operate on key ModuleCode sends /key/ModuleCode as the HTTP path。 With a path that identifies a key,
the server should support the following key-value operations over the HTTP-like protocol:
Insertion and update of avalue
a。For the request, the HTTP method is “POST”, and the value to be inserted or updated shouldfollow the header as the content  There should also be a “Content-Length” header indicating the number of bytes of the value string。network programming代写
b。The server should respond with a “200” status code after inserting or updating the value。 In this case, the client always expects the insertion or update to be
2。Retrieval
a。For the request, the HTTP method is “GET”, and there is no content
b。Forthe response, if the key does not exist in the store, the server returns a “404”  Otherwise, the server should return a “200” code, send the correct “Content-Length” header and then the value string as the content body。
3。Deletion
a。The HTTP method of the request is “DELETE”, and there is no content
b。Forthe response, if the key does not exist, the server returns a “404”  Otherwise, it should delete the key-value pair from the store and respond with a “200” code and the deleted value string as the content body。 The “Content-Length” header should also be sent accordingly