mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
s/websocket/WebSocket in docs
This commit is contained in:
@ -224,7 +224,7 @@ impl MessageType for Request {
|
||||
let decoder = match length {
|
||||
PayloadLength::Payload(pl) => pl,
|
||||
PayloadLength::UpgradeWebSocket => {
|
||||
// upgrade(websocket)
|
||||
// upgrade (WebSocket)
|
||||
PayloadType::Stream(PayloadDecoder::eof())
|
||||
}
|
||||
PayloadLength::None => {
|
||||
|
@ -54,7 +54,7 @@ pub enum Frame {
|
||||
Close(Option<CloseReason>),
|
||||
}
|
||||
|
||||
/// A `WebSocket` continuation item.
|
||||
/// A WebSocket continuation item.
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Item {
|
||||
FirstText(Bytes),
|
||||
@ -79,7 +79,7 @@ bitflags! {
|
||||
}
|
||||
|
||||
impl Codec {
|
||||
/// Create new websocket frames decoder.
|
||||
/// Create new WebSocket frames decoder.
|
||||
pub fn new() -> Codec {
|
||||
Codec {
|
||||
max_size: 65_536,
|
||||
|
@ -7,7 +7,7 @@ use crate::ws::mask::apply_mask;
|
||||
use crate::ws::proto::{CloseCode, CloseReason, OpCode};
|
||||
use crate::ws::ProtocolError;
|
||||
|
||||
/// A struct representing a `WebSocket` frame.
|
||||
/// A struct representing a WebSocket frame.
|
||||
#[derive(Debug)]
|
||||
pub struct Parser;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! WebSocket protocol support.
|
||||
//! WebSocket protocol.
|
||||
//!
|
||||
//! To setup a WebSocket, first do web socket handshake then on success convert `Payload` into a
|
||||
//! To setup a WebSocket, first perform the WebSocket handshake then on success convert `Payload` into a
|
||||
//! `WsStream` stream and then use `WsWriter` to communicate with the peer.
|
||||
|
||||
use std::io;
|
||||
@ -76,7 +76,7 @@ pub enum HandshakeError {
|
||||
#[display(fmt = "Method not allowed.")]
|
||||
GetMethodRequired,
|
||||
|
||||
/// Upgrade header if not set to websocket.
|
||||
/// Upgrade header if not set to WebSocket.
|
||||
#[display(fmt = "WebSocket upgrade is expected.")]
|
||||
NoWebsocketUpgrade,
|
||||
|
||||
@ -88,7 +88,7 @@ pub enum HandshakeError {
|
||||
#[display(fmt = "WebSocket version header is required.")]
|
||||
NoVersionHeader,
|
||||
|
||||
/// Unsupported websocket version.
|
||||
/// Unsupported WebSocket version.
|
||||
#[display(fmt = "Unsupported version.")]
|
||||
UnsupportedVersion,
|
||||
|
||||
@ -127,20 +127,20 @@ impl ResponseError for HandshakeError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Verify `WebSocket` handshake request and create handshake response.
|
||||
/// Verify WebSocket handshake request and create handshake response.
|
||||
pub fn handshake(req: &RequestHead) -> Result<ResponseBuilder, HandshakeError> {
|
||||
verify_handshake(req)?;
|
||||
Ok(handshake_response(req))
|
||||
}
|
||||
|
||||
/// Verify `WebSocket` handshake request.
|
||||
/// Verify WebSocket handshake request.
|
||||
pub fn verify_handshake(req: &RequestHead) -> Result<(), HandshakeError> {
|
||||
// WebSocket accepts only GET
|
||||
if req.method != Method::GET {
|
||||
return Err(HandshakeError::GetMethodRequired);
|
||||
}
|
||||
|
||||
// Check for "UPGRADE" to websocket header
|
||||
// Check for "UPGRADE" to WebSocket header
|
||||
let has_hdr = if let Some(hdr) = req.headers().get(header::UPGRADE) {
|
||||
if let Ok(s) = hdr.to_str() {
|
||||
s.to_ascii_lowercase().contains("websocket")
|
||||
@ -181,7 +181,7 @@ pub fn verify_handshake(req: &RequestHead) -> Result<(), HandshakeError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Create websocket handshake response
|
||||
/// Create WebSocket handshake response.
|
||||
///
|
||||
/// This function returns handshake `Response`, ready to send to peer.
|
||||
pub fn handshake_response(req: &RequestHead) -> ResponseBuilder {
|
||||
|
@ -74,8 +74,7 @@ impl From<u8> for OpCode {
|
||||
}
|
||||
}
|
||||
|
||||
/// Status code used to indicate why an endpoint is closing the `WebSocket`
|
||||
/// connection.
|
||||
/// Status code used to indicate why an endpoint is closing the WebSocket connection.
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
|
||||
pub enum CloseCode {
|
||||
/// Indicates a normal closure, meaning that the purpose for
|
||||
|
Reference in New Issue
Block a user