summaryrefslogtreecommitdiff
path: root/lib/vquic/ngtcp2.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-08-20 11:01:36 +0200
committerDaniel Stenberg <daniel@haxx.se>2019-08-20 16:53:40 +0200
commit2056175dc2225337ee425c47e482bcf5bc397d5b (patch)
tree49c4a6dd5d3b59c452436c9a73154a0d2a10cf31 /lib/vquic/ngtcp2.c
parent99775438d61f33222297ab7068c79022063555a8 (diff)
downloadcurl-2056175dc2225337ee425c47e482bcf5bc397d5b.tar.gz
ngtcp2: make postfields-set posts work
Closes #4242
Diffstat (limited to 'lib/vquic/ngtcp2.c')
-rw-r--r--lib/vquic/ngtcp2.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/lib/vquic/ngtcp2.c b/lib/vquic/ngtcp2.c
index 9a1fd1690..f9de76960 100644
--- a/lib/vquic/ngtcp2.c
+++ b/lib/vquic/ngtcp2.c
@@ -1497,6 +1497,28 @@ static ssize_t ngh3_stream_recv(struct connectdata *conn,
return -1;
}
+static int cb_h3_readfunction(nghttp3_conn *conn, int64_t stream_id,
+ const uint8_t **pdata,
+ size_t *pdatalen, uint32_t *pflags,
+ void *user_data, void *stream_user_data)
+{
+ struct Curl_easy *data = stream_user_data;
+ (void)conn;
+ (void)stream_id;
+ (void)user_data;
+
+ fprintf(stderr, "called cb_h3_readfunction\n");
+
+ if(data->set.postfields) {
+ *pdata = data->set.postfields;
+ *pdatalen = data->state.infilesize;
+ *pflags = NGHTTP3_DATA_FLAG_EOF;
+ return 0;
+ }
+
+ return 0;
+}
+
/* Index where :authority header field will appear in request header
field list. */
#define AUTHORITY_DST_IDX 3
@@ -1690,28 +1712,25 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
case HTTPREQ_POST:
case HTTPREQ_POST_FORM:
case HTTPREQ_POST_MIME:
- case HTTPREQ_PUT:
+ case HTTPREQ_PUT: {
+ nghttp3_data_reader data_reader;
if(data->state.infilesize != -1)
stream->upload_left = data->state.infilesize;
else
/* data sending without specifying the data amount up front */
stream->upload_left = -1; /* unknown, but not zero */
-#if 0
- stream3_id = quiche_h3_send_request(qs->h3c, qs->conn, nva, nheader,
- stream->upload_left ? FALSE: TRUE);
- if((stream3_id >= 0) && data->set.postfields) {
- ssize_t sent = quiche_h3_send_body(qs->h3c, qs->conn, stream3_id,
- (uint8_t *)data->set.postfields,
- stream->upload_left, TRUE);
- if(sent <= 0) {
- failf(data, "quiche_h3_send_body failed!");
- result = CURLE_SEND_ERROR;
- }
- stream->upload_left = 0; /* nothing left to send */
+ data_reader.read_data = cb_h3_readfunction;
+
+ rc = nghttp3_conn_submit_request(qs->h3conn, stream->stream3_id,
+ nva, nheader, &data_reader,
+ conn->data);
+ if(rc) {
+ result = CURLE_SEND_ERROR;
+ goto fail;
}
-#endif
break;
+ }
default:
stream->upload_left = 0; /* nothing left to send */
rc = nghttp3_conn_submit_request(qs->h3conn, stream->stream3_id,