uclient-http: Implement error handling for header-sending Add some error handling for errors during assembly of headers Signed-off-by: Tobias Schramm <tobleminer@gmail.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
uclient-http: Handle memory allocation failure Add null pointer check to allocation of uclient_http struct Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
uclient-http: auth digest: Handle multiple possible memory allocation failures Add null pointer checks to allocation of buffers for authentication parameters Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
uclient-http: basic auth: Handle memory allocation failure Allocation of the base64 buffer might fail, resulting in a null ptr being passed to base64_encode as a target buffer Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
uclient-http: fix Host: header for literal IPv6 addresses For literal IPv6 addresses, the host header must have the form Host: [...] including the square brackets, as it may also contain a port. Some webservers ignore the missing brackets, while others will return error 400. IPv6 addresses are determined by searching for ':' characters in the host, as neither IPv4 addresses nor DNS names can contain colons. An alternative would be to add a flag to the uclient_url struct; but as this struct is exposed in public headers, such a change could be considered an ABI change, making a backport difficult. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> Acked-by: Jo-Philipp Wich <jo@mein.io>
Fix unused results warnings Fixes: uclient-http.c:385:8: error: ignoring return value of 'fread', declared with attribute warn_unused_result [-Werror=unused-result] fread(&val, sizeof(val), 1, f); ^ uclient-fetch.c: In function 'main': uclient-fetch.c:664:12: error: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Werror=unused-result] asprintf(&auth_str, "%s:%s", username, password); ^ uclient-fetch.c: In function 'read_data_cb': uclient-fetch.c:269:9: error: ignoring return value of 'write', declared with attribute warn_unused_result [-Werror=unused-result] write(output_fd, buf, len); Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
uclient-http: send correct "Host:" header if port is set When connecting to a website with a special port, uclient-fetch connects to the correct port, but is sending an incorrect Host: header without the corresponding port. Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
http: add support for relative location on redirect Signed-off-by: Felix Fietkau <nbd@nbd.name>
http: allow sending message body for DELETE request Sending entity within DELETE is not forbidden by RFC 7231, see section 4.3.5. DELETE: > A payload within a DELETE request message has no defined semantics; > sending a payload body on a DELETE request might cause some existing > implementations to reject the request. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
http: use usock_inet_timeout() Signed-off-by: Felix Fietkau <nbd@openwrt.org>
http: add support for specifying ipv4/ipv6 preference Signed-off-by: Felix Fietkau <nbd@openwrt.org>
http: assume data EOF if the connection terminates Signed-off-by: Felix Fietkau <nbd@openwrt.org>
http: fix processing server http data separated by \n instead of \r\n Signed-off-by: Felix Fietkau <nbd@openwrt.org>
http: add proper error handling to uclient_http_redirect() Signed-off-by: Felix Fietkau <nbd@openwrt.org>
http: fix connection close handling on auth Signed-off-by: Felix Fietkau <nbd@openwrt.org>
uclient-http: use blocking connect, switch to non-blocking later. fixes ipv6 -> ipv4 fallback Signed-off-by: Felix Fietkau <nbd@openwrt.org>
http: detect connect failure Signed-off-by: Felix Fietkau <nbd@openwrt.org>
http: add proxy support Signed-off-by: Felix Fietkau <nbd@openwrt.org>
http: allow the header_done callback to reset the client state Signed-off-by: Felix Fietkau <nbd@openwrt.org>
http: get remote address from usock instead of using getpeername Signed-off-by: Felix Fietkau <nbd@openwrt.org>