Refine documentation according to latest code

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
This commit is contained in:
Liu Jiang
2020-03-23 21:23:12 +08:00
committed by Adrian Catangiu
parent fbb4d5392a
commit aefdd1be46
3 changed files with 4 additions and 6 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ impl<T: Read + Write> HttpConnection<T> {
} }
} }
// 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. // The return value represents the end index of what we have just appended.
fn read_bytes(&mut self) -> Result<usize, ConnectionError> { fn read_bytes(&mut self) -> Result<usize, ConnectionError> {
// Append new bytes to what we already have in the buffer. // Append new bytes to what we already have in the buffer.
+2 -4
View File
@@ -9,7 +9,7 @@ use crate::common::{Body, Method, Version};
pub use crate::common::RequestError; 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 /// Returns the starting position of the `sequence` in `bytes` or `None` if the
/// `sequence` is not found. /// `sequence` is not found.
@@ -153,8 +153,6 @@ impl Request {
/// * Request Line: "GET SP Request-uri SP HTTP/1.0 CRLF" - Mandatory </br> /// * Request Line: "GET SP Request-uri SP HTTP/1.0 CRLF" - Mandatory </br>
/// * Request Headers "<headers> CRLF"- Optional </br> /// * Request Headers "<headers> CRLF"- Optional </br>
/// * Entity Body - Optional </br> /// * Entity Body - Optional </br>
/// 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 /// The only supported method is GET and the HTTP protocol is expected to be HTTP/1.0
/// or HTTP/1.1. /// or HTTP/1.1.
/// ///
@@ -167,7 +165,7 @@ impl Request {
/// extern crate micro_http; /// extern crate micro_http;
/// use micro_http::Request; /// 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<Self, RequestError> { pub fn try_from(byte_stream: &[u8]) -> Result<Self, RequestError> {
// The first line of the request is the Request Line. The line ending is CR LF. // The first line of the request is the Request Line. The line ending is CR LF.
+1 -1
View File
@@ -92,8 +92,8 @@ impl ResponseHeaders {
buf.write_all(Header::Server.raw())?; buf.write_all(Header::Server.raw())?;
buf.write_all(&[COLON, SP])?; buf.write_all(&[COLON, SP])?;
buf.write_all(self.server.as_bytes())?; buf.write_all(self.server.as_bytes())?;
buf.write_all(&[CR, LF])?; buf.write_all(&[CR, LF])?;
buf.write_all(b"Connection: keep-alive")?; buf.write_all(b"Connection: keep-alive")?;
buf.write_all(&[CR, LF])?; buf.write_all(&[CR, LF])?;