Commit Graph

131 Commits

Author SHA1 Message Date
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Uku Loskit
98ad5a7141 LibHTTP: Fix issues with HTTP POST request and requests with a body
The previous implementation created invalid HTTP requests in cases
where the request method was POST or when the request contained a
body. There were two bugs for these cases:

1) the 'Content-Type' header was sent twice
2) a stray CRLF was appended to the request
2023-10-31 07:09:26 +01:00
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Tim Ledbetter
9fefb434f2 LibHTTP: Return an error if HTTP request URL is not valid UTF-8 2023-10-06 11:28:17 +03:30
Tim Schumacher
dbc25f18ec LibCompress: Let BrotliDecompressionStream take a MaybeOwned 2023-08-23 12:03:37 +01:00
Tim Schumacher
8a853278d0 LibCompress: Port ZlibDecompressor to AK::Stream 2023-08-23 12:03:37 +01:00
Shannon Booth
21fe86d235 AK: Port URL::m_query from DeprecatedString to String 2023-08-13 15:03:53 -06:00
Shannon Booth
55a01e72ca AK: Port URL username/password from DeprecatedString to String
And for cases that just need to check whether the password/username is
empty, add a raw_{password,username} helper to avoid any allocation.
2023-08-13 15:03:53 -06:00
Shannon Booth
8751be09f9 AK: Serialize URL hosts with 'concept-host-serializer'
In order to follow spec text to achieve this, we need to change the
underlying representation of a host in AK::URL to deserialized format.
Before this, we were parsing the host and then immediately serializing
it again.

Making that change resulted in a whole bunch of fallout.

After this change, callers can access the serialized data through
this concept-host-serializer. The functional end result of this
change is that IPv6 hosts are now correctly serialized to be
surrounded with '[' and ']'.
2023-07-31 05:18:51 +02:00
Lucas CHOLLET
ff47223301 LibCore: Make NetworkJob::start() take a Stream::BufferedSocketBase&
It used to take a plain `Socket` and cast it to a `BufferedSocketBase`,
which can lead to unpleasant result when used with a non-buffered
`Socket`.
2023-07-03 23:29:28 +02:00
Lucas CHOLLET
b46667639f LibHTTP: Make HttpRequest return its method name as a StringView 2023-07-03 23:29:28 +02:00
Tim Ledbetter
1a17e08f87 Everywhere: Correctly report progress of downloads larger than 4GiB
This commit changes the variables used to represent the size and
progress of downloads from u32 to u64. This allows `pro` and
`Browser` to report the total size and progress of a download
correctly for downloads larger than 4GiB.
2023-06-19 06:13:19 +02:00
MacDue
35612c6a7f AK+Everywhere: Change URL::path() to serialize_path()
This now defaults to serializing the path with percent decoded segments
(which is what all callers expect), but has an option not to. This fixes
`file://` URLs with spaces in their paths.

The name has been changed to serialize_path() path to make it more clear
that this method will generate a new string each call (except for the
cannot_be_a_base_url() case). A few callers have then been updated to
avoid repeatedly calling this function.
2023-04-15 06:37:04 +02:00
Ali Mohammad Pur
c7409af627 LibHTTP: Tolerate extra \r\n in chunked-encoding last block size
Some servers put CR/LF there, so let's tolerate that behaviour.
Fixes #18151.
2023-04-02 20:42:39 +02:00
Aliaksandr Kalenik
7b8a857e30 LibHTTP: Return error if request is incomplete
If there is not enough input to completely parse HTTP request we need
to return error and handle it in HTTP server.
2023-03-26 17:56:17 +02:00
Aliaksandr Kalenik
9220cdc285 LibHTTP+WebDriver+WebServer: Return error from HTTP request parser 2023-03-26 17:56:17 +02:00
Tim Schumacher
ecd1862859 AK: Rename Stream::write_entire_buffer to Stream::write_until_depleted
No functional changes.
2023-03-13 15:16:20 +00:00
Tim Schumacher
d5871f5717 AK: Rename Stream::{read,write} to Stream::{read_some,write_some}
Similar to POSIX read, the basic read and write functions of AK::Stream
do not have a lower limit of how much data they read or write (apart
from "none at all").

Rename the functions to "read some [data]" and "write some [data]" (with
"data" being omitted, since everything here is reading and writing data)
to make them sufficiently distinct from the functions that ensure to
use the entire buffer (which should be the go-to function for most
usages).

No functional changes, just a lot of new FIXMEs.
2023-03-13 15:16:20 +00:00
Andreas Kling
a504ac3e2a Everywhere: Rename equals_ignoring_case => equals_ignoring_ascii_case
Let's make it clear that these functions deal with ASCII case only.
2023-03-10 13:15:44 +01:00
Linus Groh
e76394d96c AK: Remove infallible version of StringBuilder::to_byte_buffer
Also drop the try_ prefix from the fallible function, as it is no longer
needed to distinguish the two.
2023-03-09 15:51:00 +00:00
Linus Groh
d0ecd81888 LibHTTP: Propagate OOM errors from HttpRequest::to_raw_request() 2023-03-09 14:51:20 +00:00
Andreas Kling
21db2b7b90 Everywhere: Remove NonnullOwnPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling
359d6e7b0b Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-06 23:46:35 +01:00
Tim Schumacher
43f98ac6e1 Everywhere: Remove the AK:: qualifier from Stream usages 2023-02-13 00:50:07 +00:00
Tim Schumacher
874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00
Tim Schumacher
a96339b72b LibCore: Move Stream-based sockets into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher
220fbcaa7e AK: Remove the fallible constructor from FixedMemoryStream 2023-02-08 17:44:32 +00:00
Tim Schumacher
093cf428a3 AK: Move memory streams from LibCore 2023-01-29 19:16:44 -07:00
Tim Schumacher
8464da1439 AK: Move Stream and SeekableStream from LibCore
`Stream` will be qualified as `AK::Stream` until we remove the
`Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is
defined by `SeekableStream`, since defining its own would require us to
qualify it with `AK::SeekMode` everywhere.
2023-01-29 19:16:44 -07:00
Linus Groh
6e7459322d AK: Remove StringBuilder::build() in favor of to_deprecated_string()
Having an alias function that only wraps another one is silly, and
keeping the more obvious name should flush out more uses of deprecated
strings.
No behavior change.
2023-01-27 20:38:49 +00:00
Tim Schumacher
63cf9b973d AK: Remove FileStream 2023-01-21 14:43:56 +01:00
Tim Schumacher
23a9d62f39 LibCompress: Rename Compress::Zlib to Compress::ZlibDecompressor
Because that's what it is, even if it mainly relies on
`DeflateDecompressor` to do the heavy lifting.
2023-01-03 10:01:09 +00:00
Ben Wiederhake
8a331d4fa0 Everywhere: Move AK/Debug.h include to using files or remove 2023-01-02 20:27:20 -05:00
ericLemanissier
9d61e59ceb LibHTTP: Propagate errors using TRY 2023-01-02 11:04:38 -05:00
Jelle Raaijmakers
25f2e4981c AK: Stop using DeprecatedString in Base64 encoding 2022-12-20 10:34:19 +01:00
Tim Schumacher
c6d71ca727 LibCore: Rename MemoryStream to FixedMemoryStream
This is to differentiate between the upcoming `AllocatingMemoryStream`,
which automatically allocates memory as needed instead of operating on a
static memory area.
2022-12-15 13:28:29 +00:00
Tim Schumacher
0bd9a94bea LibHTTP: Don't read and drop data if status line can't be read
The idea of reading some amount of data presumably was to check if the
stream is still operable. However, this permanently breaks the request
format, as those 64 bytes are just lost forever.

Instead, just let the request fail instantly for now and think about
making it retry some time in the future. Since `can_read_line` updates
the read buffer beforehand, this should only happen in the rarest of
cases anyways.
2022-12-12 20:59:03 -07:00
Tim Schumacher
30abd47099 LibCompress: Port DeflateDecompressor to Core::Stream 2022-12-12 16:21:39 +00:00
Tim Schumacher
9a3e95785e LibCore: Propagate errors from Stream::*_entire_buffer 2022-12-12 14:16:42 +01:00
Tim Schumacher
6c7c5a6786 LibCore: Rename Stream::*_or_error to *_entire_buffer
All of our functions are `_or_error` (or are about to be), and maybe
making it less reminiscient of AK::Stream will make people use it more.
2022-12-12 14:16:42 +01:00
Tim Schumacher
ed4c2f2f8e LibCore: Rename Stream::read_all to read_until_eof
This generally seems like a better name, especially if we somehow also
need a better name for "read the entire buffer, but not the entire file"
somewhere down the line.
2022-12-12 14:16:42 +01:00
Tim Schumacher
f93c7fbb5e LibCompress: Port GzipDecompressor to Core::Stream 2022-12-10 12:05:55 +00:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Tim Schumacher
d402f6cdb3 LibCore: Add support for ReadonlyBytes to MemoryStream 2022-11-30 12:09:53 +00:00
Luke Wilde
b8b263d9c3 LibHTTP: Always send Content-Length header in POST requests
Required by Google services, Content-Length should always been sent,
even when there is no body.
2022-11-07 14:10:41 +01:00
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
demostanis
3e8b5ac920 AK+Everywhere: Turn bool keep_empty to an enum in split* functions 2022-10-24 23:29:18 +01:00
Luke Wilde
41d6307c17 LibHTTP: Fix not consuming the last byte of body in from_raw_request
`index + 1` was not correct. For example, if the body has two bytes, we
would consume the first byte and increment the index. We then add one
to the index and see it's equal to the size, so we take this one byte
and set the body result to it. The while loop would still continue and
we consume the second byte, adding it to the temporary buffer. We see
that the index is above the size, so we don't update the body, dropping
the last byte on the floor.
2022-10-18 23:18:20 +02:00
Sam Atkins
f754f45680 LibHTTP: Include request body in HttpRequest::from_raw_request() 2022-10-11 21:52:13 +02:00