From 20f1ec02b0b1b4727b2c6e96a3b04e4785ff3228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 23 May 2017 14:40:16 +0200 Subject: Add building of PRIORITY frame --- src/cow_http2.erl | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/cow_http2.erl') diff --git a/src/cow_http2.erl b/src/cow_http2.erl index efc3ad8..ef7d439 100644 --- a/src/cow_http2.erl +++ b/src/cow_http2.erl @@ -23,6 +23,7 @@ -export([data/3]). -export([data_header/3]). -export([headers/3]). +-export([priority/4]). -export([rst_stream/2]). -export([settings/1]). -export([settings_payload/1]). @@ -359,6 +360,10 @@ headers(StreamID, IsFin, HeaderBlock) -> FlagEndHeaders = 1, [<< Len:24, 1:8, 0:5, FlagEndHeaders:1, 0:1, FlagEndStream:1, 0:1, StreamID:31 >>, HeaderBlock]. +priority(StreamID, E, DepStreamID, Weight) -> + FlagExclusive = exclusive(E), + << 5:24, 2:8, 0:9, StreamID:31, FlagExclusive:1, DepStreamID:31, Weight:8 >>. + rst_stream(StreamID, Reason) -> ErrorCode = error_code(Reason), << 4:24, 3:8, 0:9, StreamID:31, ErrorCode:32 >>. @@ -400,6 +405,9 @@ window_update(StreamID, Increment) when Increment =< 16#7fffffff -> flag_fin(nofin) -> 0; flag_fin(fin) -> 1. +exclusive(shared) -> 0; +exclusive(exclusive) -> 1. + error_code(no_error) -> 0; error_code(protocol_error) -> 1; error_code(internal_error) -> 2; -- cgit v1.2.3