Skip to content

Commit 0b9a0e1

Browse files
Leonardo Alminanaedsiper
authored andcommitted
http_server: removed deprecated code and added window update handling
Signed-off-by: Leonardo Alminana <[email protected]>
1 parent b9323dc commit 0b9a0e1

File tree

1 file changed

+6
-104
lines changed

1 file changed

+6
-104
lines changed

src/http_server/flb_http_server_http2.c

Lines changed: 6 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -123,110 +123,6 @@ int flb_http2_response_set_body(struct flb_http_response *response,
123123
return 0;
124124
}
125125

126-
/*
127-
int flb_http2_response_commit(struct flb_http_response *response)
128-
{
129-
char status_as_text[16];
130-
struct mk_list *header_iterator;
131-
struct flb_http_server_session *parent_session;
132-
nghttp2_data_provider data_provider;
133-
size_t header_count;
134-
size_t header_index;
135-
struct flb_hash_table_entry *header_entry;
136-
nghttp2_nv *headers;
137-
struct flb_http2_server_session *session;
138-
struct flb_http_stream *stream;
139-
int result;
140-
141-
FLB_HTTP_STREAM_GET_SESSION(response->stream, &parent_session);
142-
143-
if (parent_session == NULL) {
144-
return -1;
145-
}
146-
147-
session = &parent_session->http2;
148-
149-
if (session == NULL) {
150-
return -1;
151-
}
152-
153-
stream = (struct flb_http_stream *) response->stream;
154-
155-
if (stream == NULL) {
156-
return -2;
157-
}
158-
159-
header_count = response->headers->total_count + 1;
160-
161-
headers = flb_calloc(header_count, sizeof(nghttp2_nv));
162-
163-
if (headers == NULL) {
164-
return -3;
165-
}
166-
167-
snprintf(status_as_text,
168-
sizeof(status_as_text) - 1,
169-
"%d",
170-
response->status);
171-
172-
headers[0].name = (uint8_t *) ":status";
173-
headers[0].namelen = strlen(":status");
174-
headers[0].value = (uint8_t *) status_as_text;
175-
headers[0].valuelen = strlen(status_as_text);
176-
177-
header_index = 1;
178-
179-
mk_list_foreach(header_iterator, &response->headers->entries) {
180-
header_entry = mk_list_entry(header_iterator,
181-
struct flb_hash_table_entry,
182-
_head_parent);
183-
184-
if (header_entry == NULL) {
185-
return -4;
186-
}
187-
188-
headers[header_index].name = (uint8_t *) header_entry->key;
189-
headers[header_index].namelen = header_entry->key_len;
190-
headers[header_index].value = (uint8_t *) header_entry->val;
191-
headers[header_index].valuelen = header_entry->val_size;
192-
193-
header_index++;
194-
}
195-
196-
data_provider.source.fd = 0;
197-
data_provider.read_callback = http2_data_source_read_callback;
198-
199-
stream->status = HTTP_STREAM_STATUS_PROCESSING;
200-
201-
result = nghttp2_submit_response(session->inner_session,
202-
stream->id,
203-
headers,
204-
header_count,
205-
&data_provider);
206-
207-
flb_free(headers);
208-
209-
if (result != 0) {
210-
stream->status = HTTP_STREAM_STATUS_ERROR;
211-
212-
return -5;
213-
}
214-
215-
result = nghttp2_session_send(session->inner_session);
216-
217-
if (result != 0) {
218-
stream->status = HTTP_STREAM_STATUS_ERROR;
219-
220-
return -6;
221-
}
222-
223-
stream->status = HTTP_STREAM_STATUS_RECEIVING_HEADERS;
224-
225-
flb_http_response_destroy(&stream->response);
226-
227-
return 0;
228-
}
229-
*/
230126
int flb_http2_response_commit(struct flb_http_response *response)
231127
{
232128
size_t trailer_header_count;
@@ -483,6 +379,12 @@ int flb_http2_server_session_ingest(struct flb_http2_server_session *session,
483379

484380
result = nghttp2_session_mem_recv(session->inner_session, buffer, length);
485381

382+
if (result < 0) {
383+
return HTTP_SERVER_PROVIDER_ERROR;
384+
}
385+
386+
result = nghttp2_session_send(session->inner_session);
387+
486388
if (result < 0) {
487389
return HTTP_SERVER_PROVIDER_ERROR;
488390
}

0 commit comments

Comments
 (0)