You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ro...@apache.org on 2015/06/29 23:46:41 UTC
[35/50] couch commit: updated refs/heads/COUCHDB-2734-header-date to
f3e022c
some more whitespace tweaks, use full bytes in payload_length/1
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/49eaab98
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/49eaab98
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/49eaab98
Branch: refs/heads/COUCHDB-2734-header-date
Commit: 49eaab98a5bf15b4f6ba0846c9e5057f10df95cb
Parents: 74d6cdc
Author: Bob Ippolito <bo...@redivi.com>
Authored: Thu Dec 26 13:06:56 2013 -0800
Committer: Bob Ippolito <bo...@redivi.com>
Committed: Thu Dec 26 13:06:56 2013 -0800
----------------------------------------------------------------------
src/mochiweb_websocket.erl | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/49eaab98/src/mochiweb_websocket.erl
----------------------------------------------------------------------
diff --git a/src/mochiweb_websocket.erl b/src/mochiweb_websocket.erl
index e5aff05..cc3127e 100644
--- a/src/mochiweb_websocket.erl
+++ b/src/mochiweb_websocket.erl
@@ -69,27 +69,23 @@ call_body(Body, Payload, State, ReplyChannel) ->
Body(Payload, State, ReplyChannel).
send(Socket, Payload, hybi) ->
- Len = payload_length(iolist_size(Payload)),
- Data = <<1:1, 0:3, 1:4, 0:1, Len/bits, Payload/binary>>,
- mochiweb_socket:send(Socket, Data);
+ Prefix = <<1:1, 0:3, 1:4, (payload_length(iolist_size(Payload)))/binary>>,
+ mochiweb_socket:send(Socket, [Prefix, Payload]);
send(Socket, Payload, hixie) ->
- Data = <<0, Payload/binary, 255>>,
- mochiweb_socket:send(Socket, Data).
+ mochiweb_socket:send(Socket, [0, Payload, 255]).
upgrade_connection(Req, Body) ->
case make_handshake(Req) of
{Version, Response} ->
Req:respond(Response),
-
Socket = Req:get(socket),
- ReplyChannel = fun(Payload) ->
+ ReplyChannel = fun (Payload) ->
?MODULE:send(Socket, Payload, Version)
end,
Reentry = fun (State) ->
?MODULE:loop(Socket, Body, State, Version, ReplyChannel)
end,
{Reentry, ReplyChannel};
-
_ ->
mochiweb_socket:close(Req:get(socket)),
exit(normal)
@@ -207,7 +203,6 @@ parse_hybi_frames(Socket, <<_Fin:1,
_MaskKey:4/binary,
_/binary-unit:8>> = PartFrame,
Acc) ->
-
ok = mochiweb_socket:setopts(Socket, [{packet, 0}, {active, once}]),
receive
{tcp_closed, _} ->
@@ -226,9 +221,9 @@ parse_hybi_frames(Socket, <<_Fin:1,
mochiweb_socket:close(Socket),
exit(normal)
after
- 5000 ->
- mochiweb_socket:close(Socket),
- exit(normal)
+ 5000 ->
+ mochiweb_socket:close(Socket),
+ exit(normal)
end;
parse_hybi_frames(S, <<_Fin:1,
_Rsv:3,
@@ -262,9 +257,9 @@ hybi_unmask(<<>>, _MaskKey, Acc) ->
payload_length(N) ->
case N of
- N when N =< 125 -> << N:7 >>;
- N when N =< 16#ffff -> << 126:7, N:16 >>;
- N when N =< 16#7fffffffffffffff -> << 127:7, N:64 >>
+ N when N =< 125 -> << N >>;
+ N when N =< 16#ffff -> << 126, N:16 >>;
+ N when N =< 16#7fffffffffffffff -> << 127, N:64 >>
end.