No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

47 líneas
2.2 KiB

hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
hace 3 años
  1. -include("eWSrv.hrl").
  2. -define(wsErr(Str), error_logger:error_msg(Str)).
  3. -define(wsErr(Format, Args), error_logger:error_msg(Format, Args)).
  4. -define(wsWarn(Format, Args), error_logger:warning_msg(Format, Args)).
  5. -define(wsInfo(Format, Args), error_logger:info_msg(Format, Args)).
  6. -define(wsGLV(Key, List, Default), wsUtil:gLV(Key, List, Default)).
  7. -define(DefWsOpts, [
  8. binary
  9. , {packet, raw}
  10. , {active, false}
  11. , {reuseaddr, true}
  12. , {nodelay, false}
  13. , {delay_send, true}
  14. , {send_timeout, 15000}
  15. , {keepalive, true}
  16. , {exit_on_close, true}
  17. , {backlog, 4096}
  18. ]).
  19. -define(CASE(Cond, Then, That), case Cond of true -> Then; _ -> That end).
  20. -export_type([
  21. sendfile_opts/0
  22. ]).
  23. -type sendfile_opts() :: [{chunk_size, non_neg_integer()}].
  24. -type stage() :: reqLine | wsHeader | wsBody | done. %% 接受http请求可能会有多个包 分四个阶接收
  25. -record(wsState, {
  26. stage = reqLine :: stage() %% 接收数据阶段
  27. , buffer = <<>> :: binary() %% 缓存接收到的数据
  28. , wsReq :: undefined | #wsReq{} %% 解析后的http
  29. , headerCnt = 0 :: pos_integer() %% header计数
  30. , temHeader = [] :: [wsHeaders()] %% 解析header临时数据
  31. , contentLength :: undefined | non_neg_integer() | chunked %% 长度
  32. , temChunked = <<>> :: binary() %% chunked 模式下保存数据
  33. , method :: wsMethod() %% 请求的method
  34. , path :: binary() %% 请求的URL
  35. , rn :: undefined | binary:cp() %% binary:cp()
  36. , socket :: undefined | inet:socket() | ssl:sslsocket() %% 连接的socket
  37. , isSsl = false :: boolean() %% 是否是ssl
  38. , wsMod :: module() %% 回调请求的模块
  39. , maxSize = infinity :: pos_integer() %% 单次允许接收的最大长度
  40. , chunkedSupp = false :: boolean() %% 是否运行 chunked
  41. }).