net: http: client: Add port number to HTTP Header
Add port number to HTTP Header. Signed-off-by: NavinSankar Velliangiri <navin@linumiz.com>
This commit is contained in:
parent
18d3499dba
commit
820bfb46bc
2 changed files with 23 additions and 6 deletions
|
@ -227,6 +227,9 @@ struct http_request {
|
|||
/** Hostname to be used in the request */
|
||||
const char *host;
|
||||
|
||||
/** Port number to be used in the request */
|
||||
const char *port;
|
||||
|
||||
/** User supplied callback function to call when payload
|
||||
* needs to be sent. This can be NULL in which case the payload field
|
||||
* in http_request is used. The idea of this payload callback is to
|
||||
|
|
|
@ -504,13 +504,27 @@ int http_client_req(int sock, struct http_request *req,
|
|||
|
||||
total_sent += ret;
|
||||
|
||||
ret = http_send_data(sock, send_buf, send_buf_max_len, &send_buf_pos,
|
||||
"Host", ": ", req->host, HTTP_CRLF, NULL);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
if (req->port) {
|
||||
ret = http_send_data(sock, send_buf, send_buf_max_len,
|
||||
&send_buf_pos, "Host", ": ", req->host,
|
||||
":", req->port, HTTP_CRLF, NULL);
|
||||
|
||||
total_sent += ret;
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
total_sent += ret;
|
||||
} else {
|
||||
ret = http_send_data(sock, send_buf, send_buf_max_len,
|
||||
&send_buf_pos, "Host", ": ", req->host,
|
||||
HTTP_CRLF, NULL);
|
||||
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
total_sent += ret;
|
||||
}
|
||||
|
||||
if (req->optional_headers_cb) {
|
||||
ret = http_flush_data(sock, send_buf, send_buf_pos);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue