Merge branch 'bugfix/http2_add_authority_field' into 'master'
http2: Include 'authority' header by default in the request See merge request idf/esp-idf!2097
This commit is contained in:
commit
d7e980865b
2 changed files with 11 additions and 3 deletions
|
@ -58,6 +58,7 @@ static int do_ssl_connect(struct sh2lib_handle *hd, int sockfd, const char *host
|
||||||
hd->ssl_ctx = ssl_ctx;
|
hd->ssl_ctx = ssl_ctx;
|
||||||
hd->ssl = ssl;
|
hd->ssl = ssl;
|
||||||
hd->sockfd = sockfd;
|
hd->sockfd = sockfd;
|
||||||
|
hd->hostname = strdup(hostname);
|
||||||
|
|
||||||
int flags = fcntl(hd->sockfd, F_GETFL, 0);
|
int flags = fcntl(hd->sockfd, F_GETFL, 0);
|
||||||
fcntl(hd->sockfd, F_SETFL, flags | O_NONBLOCK);
|
fcntl(hd->sockfd, F_SETFL, flags | O_NONBLOCK);
|
||||||
|
@ -331,6 +332,10 @@ void sh2lib_free(struct sh2lib_handle *hd)
|
||||||
close(hd->sockfd);
|
close(hd->sockfd);
|
||||||
hd->ssl_ctx = 0;
|
hd->ssl_ctx = 0;
|
||||||
}
|
}
|
||||||
|
if (hd->hostname) {
|
||||||
|
free(hd->hostname);
|
||||||
|
hd->hostname = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int sh2lib_execute(struct sh2lib_handle *hd)
|
int sh2lib_execute(struct sh2lib_handle *hd)
|
||||||
|
@ -361,10 +366,10 @@ int sh2lib_do_get_with_nv(struct sh2lib_handle *hd, const nghttp2_nv *nva, size_
|
||||||
|
|
||||||
int sh2lib_do_get(struct sh2lib_handle *hd, const char *path, sh2lib_frame_data_recv_cb_t recv_cb)
|
int sh2lib_do_get(struct sh2lib_handle *hd, const char *path, sh2lib_frame_data_recv_cb_t recv_cb)
|
||||||
{
|
{
|
||||||
#define HTTP2_PATH_NV ":path"
|
|
||||||
const nghttp2_nv nva[] = { SH2LIB_MAKE_NV(":method", "GET"),
|
const nghttp2_nv nva[] = { SH2LIB_MAKE_NV(":method", "GET"),
|
||||||
SH2LIB_MAKE_NV(":scheme", "https"),
|
SH2LIB_MAKE_NV(":scheme", "https"),
|
||||||
{(uint8_t *)HTTP2_PATH_NV, (uint8_t *)path, strlen(HTTP2_PATH_NV), strlen(path), NGHTTP2_NV_FLAG_NONE},
|
SH2LIB_MAKE_NV(":authority", hd->hostname),
|
||||||
|
SH2LIB_MAKE_NV(":path", path),
|
||||||
};
|
};
|
||||||
return sh2lib_do_get_with_nv(hd, nva, sizeof(nva) / sizeof(nva[0]), recv_cb);
|
return sh2lib_do_get_with_nv(hd, nva, sizeof(nva) / sizeof(nva[0]), recv_cb);
|
||||||
}
|
}
|
||||||
|
@ -400,6 +405,7 @@ int sh2lib_do_post(struct sh2lib_handle *hd, const char *path,
|
||||||
{
|
{
|
||||||
const nghttp2_nv nva[] = { SH2LIB_MAKE_NV(":method", "POST"),
|
const nghttp2_nv nva[] = { SH2LIB_MAKE_NV(":method", "POST"),
|
||||||
SH2LIB_MAKE_NV(":scheme", "https"),
|
SH2LIB_MAKE_NV(":scheme", "https"),
|
||||||
|
SH2LIB_MAKE_NV(":authority", hd->hostname),
|
||||||
SH2LIB_MAKE_NV(":path", path),
|
SH2LIB_MAKE_NV(":path", path),
|
||||||
};
|
};
|
||||||
return sh2lib_do_putpost_with_nv(hd, nva, sizeof(nva) / sizeof(nva[0]), send_cb, recv_cb);
|
return sh2lib_do_putpost_with_nv(hd, nva, sizeof(nva) / sizeof(nva[0]), send_cb, recv_cb);
|
||||||
|
@ -411,6 +417,7 @@ int sh2lib_do_put(struct sh2lib_handle *hd, const char *path,
|
||||||
{
|
{
|
||||||
const nghttp2_nv nva[] = { SH2LIB_MAKE_NV(":method", "PUT"),
|
const nghttp2_nv nva[] = { SH2LIB_MAKE_NV(":method", "PUT"),
|
||||||
SH2LIB_MAKE_NV(":scheme", "https"),
|
SH2LIB_MAKE_NV(":scheme", "https"),
|
||||||
|
SH2LIB_MAKE_NV(":authority", hd->hostname),
|
||||||
SH2LIB_MAKE_NV(":path", path),
|
SH2LIB_MAKE_NV(":path", path),
|
||||||
};
|
};
|
||||||
return sh2lib_do_putpost_with_nv(hd, nva, sizeof(nva) / sizeof(nva[0]), send_cb, recv_cb);
|
return sh2lib_do_putpost_with_nv(hd, nva, sizeof(nva) / sizeof(nva[0]), send_cb, recv_cb);
|
||||||
|
|
|
@ -40,6 +40,7 @@ struct sh2lib_handle {
|
||||||
SSL *ssl; /*!< Pointer to the SSL handle */
|
SSL *ssl; /*!< Pointer to the SSL handle */
|
||||||
nghttp2_session *http2_sess; /*!< Pointer to the HTTP2 session handle */
|
nghttp2_session *http2_sess; /*!< Pointer to the HTTP2 session handle */
|
||||||
int sockfd; /*!< Socket file descriptor */
|
int sockfd; /*!< Socket file descriptor */
|
||||||
|
char *hostname; /*!< The hostname we are connected to */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Flag indicating receive stream is reset */
|
/** Flag indicating receive stream is reset */
|
||||||
|
|
Loading…
Reference in a new issue