summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibHTTP
AgeCommit message (Collapse)Author
2021-09-19LibTLS: Use a setter for on_tls_ready_to_write with some more smartsAli Mohammad Pur
The callback should be called as soon as the connection is established, and if we actually set the callback when it already is, we expect it to be called immediately.
2021-09-19RequestServer+LibHTTP+LibGemini: Cache connections to the same hostAli Mohammad Pur
This makes connections (particularly TLS-based ones) do the handshaking stuff only once. Currently the cache is configured to keep at most two connections evenly balanced in queue size, and with a grace period of 10s after the last queued job has finished (after which the connection will be dropped).
2021-09-19LibHTTP: Exit the read loop early when there cannot be any further dataAli Mohammad Pur
2021-09-14AK: Make URL::m_port an Optional<u16>, Expose raw port getterIdan Horowitz
Our current way of signalling a missing port with m_port == 0 was lacking, as 0 is a valid port number in URLs.
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur
2021-09-02Userland: Migrate to argument-less deferred_invokesin-ack
Only one place used this argument and it was to hold on to a strong ref for the object. Since we already do that now, there's no need to keep this argument around since this can be easily captured. This commit contains no changes.
2021-08-13LibCore+LibHTTP: Check the status of the socket after EINPROGRESSbrapru
Previously the system would assume the socket was connected after the file descriptor became writeable. Just because the fd is signaled as ready for output does not necessarily indicate the socket is connected. Instead, we should check the status of the socket with SO_ERROR and handle successes/errors accordingly.
2021-06-30LibHTTP: Finish the request up on TLS connection finishAli Mohammad Pur
...unless it has already been done. Otherwise we'd be spinning in RequestServer waiting for more read events.
2021-06-29LibHTTP: Relax the finish_up() "must be called once" limitation a bitAli Mohammad Pur
It's alright for this function to be called multiple times, as it quits early when a partial flush doesn't empty the download buffer. Relax the assertion to having scheduled "did_finish()" only once.
2021-06-28LibHTTP: Ensure finish_up() is not called more than onceAli Mohammad Pur
There's no reason to manually call it on TLS close, the HTTP reading logic is smart enough to handle connection closes transparently. Fixes #8211.
2021-06-11LibHTTP: Add HTTP Basic Authentication header generation and parsingMax Wipfli
This patch adds two new static methods to HttpRequest. get_http_basic_authentication_header generates a "Authorization" header from a given URL, where as parse_http_basic_authentication_header parses an "Authorization" header into username and password.
2021-06-11LibHTTP: Implement getting the correct reason phrase from HttpResponseMax Wipfli
This adds a reason_phrase() getter and a static reason_phrase_for_code() to the HttpResponse class. It also changes the class to use east const style.
2021-06-01LibHTTP: Percent encode/decode request URIMax Wipfli
This percent encodes/decodes the request URI when creating or parsing raw HTTP requests. This is necessary because AK::URL now contains percent decoded data, meaning we have to re-encode it for creating raw requests.
2021-05-31LibHTTP: Replace fprintf(stderr) with warnln()Linus Groh
2021-05-19LibHTTP: Relax the assertion on extra reads after transfer is finishedAli Mohammad Pur
This was added in #4831, but it didn't account for extra newlines after the response (seems like some servers like to do this).
2021-05-17LibHTTP: Make sure we're not sending an empty path in requestsGunnar Beutner
When the path component of the request URL was empty we'd end up sending requests like "GET HTTP/1.1" (note the missing /). This ensures that we always send a path.
2021-05-16AK+Userland: Remove nullability feature for the ByteBuffer typeGunnar Beutner
Nobody seems to use this particular feature, in fact there were some bugs which were uncovered by removing operator bool.
2021-05-12RequestServer: Only attempt to flush() on a timerAli Mohammad Pur
...instead of doing so immediately. This makes RequestServer not spin as much when its client isn't fast enough to empty the download pipe. It also has the nice benefit of allowing multiple downloads to happen at the same time without one blocking the other too much.
2021-05-01Everywhere: Turn #if *_DEBUG into dbgln_if/if constexprGunnar Beutner
2021-04-29Everywhere: Use "the SerenityOS developers." in copyright headersLinus Groh
We had some inconsistencies before: - Sometimes "The", sometimes "the" - Sometimes trailing ".", sometimes no trailing "." I picked the most common one (lowecase "the", trailing ".") and applied it to all copyright headers. By using the exact same string everywhere we can ensure nothing gets missed during a global search (and replace), and that these inconsistencies are not spread any further (as copyright headers are commonly copied to new files).
2021-04-23AK: Rename adopt() to adopt_ref()Andreas Kling
This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-14LibHTTP: Trim the whitespace around the Transfer-Encoding header valueAnotherTest
Fixes #6302.
2021-04-12LibHTTP: Handle running out of input between chunk body and ending CRLFAnotherTest
Fixes an issue where LibHTTP would incorrectly detect an end of stream when it runs out of TLS application data between the chunk body and its ending CRLF.
2021-03-22LibHTTP: Add support for the deflate content encodingLuke
2021-03-03LibCore+LibHTTP+LibGfx: Switch to LibCompressIdan Horowitz
This commit removes the only 3rd party library (and its usages) in serenity: puff, which is used for deflate decompression. and replaces it with the existing original serenity implementation in LibCompress. :^)
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-08Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)AnotherTest
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
2021-01-25Everywhere: Hook up remaining debug macros to Debug.h.asynts
2021-01-25Everywhere: Debug macros instead of constexpr.asynts
This was done with the following script: find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \; find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
2021-01-25Everywhere: Remove unnecessary debug comments.asynts
It would be tempting to uncomment these statements, but that won't work with the new changes. This was done with the following commands: find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/#define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/#define/ { toggle = 1 }' {} \; find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/ #define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/ #define/ { toggle = 1 }' {} \;
2021-01-25Everywhere: Use CMake to generate AK/Debug.h.asynts
This was done with the help of several scripts, I dump them here to easily find them later: awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in) do find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \; done # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list. awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in
2021-01-24LibHTTP: Always read in the last chunkLuke
This was accidentally put behind a debug flag. Fixes #5080
2021-01-22Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling