From aefdd1be462ca614de2bf27833e424d9c3f96b62 Mon Sep 17 00:00:00 2001 From: Liu Jiang Date: Mon, 23 Mar 2020 21:23:12 +0800 Subject: [PATCH] Refine documentation according to latest code Signed-off-by: Liu Jiang --- src/connection.rs | 2 +- src/request.rs | 6 ++---- src/response.rs | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/connection.rs b/src/connection.rs index 1b98a9c..450ecdb 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -114,7 +114,7 @@ impl HttpConnection { } } - // Reads a maximum of 1024 bytes from the stream into `buffer`. + // Reads a maximum of `BUFFER_SIZE` bytes from the stream into `buffer`. // The return value represents the end index of what we have just appended. fn read_bytes(&mut self) -> Result { // Append new bytes to what we already have in the buffer. diff --git a/src/request.rs b/src/request.rs index 2f59e1c..2036b4b 100644 --- a/src/request.rs +++ b/src/request.rs @@ -9,7 +9,7 @@ use crate::common::{Body, Method, Version}; pub use crate::common::RequestError; -/// Finds the first occurence of `sequence` in the `bytes` slice. +/// Finds the first occurrence of `sequence` in the `bytes` slice. /// /// Returns the starting position of the `sequence` in `bytes` or `None` if the /// `sequence` is not found. @@ -153,8 +153,6 @@ impl Request { /// * Request Line: "GET SP Request-uri SP HTTP/1.0 CRLF" - Mandatory
/// * Request Headers " CRLF"- Optional
/// * Entity Body - Optional
- /// The request headers and the entity body is not parsed and None is returned because - /// these are not used by the MMDS server. /// The only supported method is GET and the HTTP protocol is expected to be HTTP/1.0 /// or HTTP/1.1. /// @@ -167,7 +165,7 @@ impl Request { /// extern crate micro_http; /// use micro_http::Request; /// - /// let http_request = Request::try_from(b"GET http://localhost/home HTTP/1.0\r\n"); + /// let http_request = Request::try_from(b"GET http://localhost/home HTTP/1.0\r\n\r\n").unwrap(); /// ``` pub fn try_from(byte_stream: &[u8]) -> Result { // The first line of the request is the Request Line. The line ending is CR LF. diff --git a/src/response.rs b/src/response.rs index e113bf0..216a43c 100644 --- a/src/response.rs +++ b/src/response.rs @@ -92,8 +92,8 @@ impl ResponseHeaders { buf.write_all(Header::Server.raw())?; buf.write_all(&[COLON, SP])?; buf.write_all(self.server.as_bytes())?; - buf.write_all(&[CR, LF])?; + buf.write_all(b"Connection: keep-alive")?; buf.write_all(&[CR, LF])?;