Browse Source

Add a cow_http2:data_header/3 function

For use with sendfile or streaming in general.
Loïc Hoguin 9 years ago
parent
commit
8645a8f197
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/cow_http2.erl

+ 5 - 2
src/cow_http2.erl

@@ -20,6 +20,7 @@
 
 %% Building.
 -export([data/3]).
+-export([data_header/3]).
 -export([headers/3]).
 -export([rst_stream/2]).
 -export([settings/1]).
@@ -299,9 +300,11 @@ parse_settings_payload(<< _:48, Rest/bits >>, Len, Settings) ->
 
 %% @todo Check size and create multiple frames if needed.
 data(StreamID, IsFin, Data) ->
-	Len = iolist_size(Data),
+	[data_header(StreamID, IsFin, iolist_size(Data)), Data].
+
+data_header(StreamID, IsFin, Len) ->
 	FlagEndStream = flag_fin(IsFin),
-	[<< Len:24, 0:15, FlagEndStream:1, 0:1, StreamID:31 >>, Data].
+	<< Len:24, 0:15, FlagEndStream:1, 0:1, StreamID:31 >>.
 
 %% @todo Check size of HeaderBlock and use CONTINUATION frames if needed.
 headers(StreamID, IsFin, HeaderBlock) ->