Commit graph

23 commits

Author SHA1 Message Date
Andreas Kling
685d5f4e25 LibProtocol: Remove use of ByteBuffer::wrap() in protocol API 2020-12-19 13:09:02 +01:00
Ben Wiederhake
8f392683c7 Userland: Fix typo in 'pro' help 2020-12-06 15:50:02 +01:00
Ben Wiederhake
4ec77ba929 Userland: Write some '--help' descriptions where appropriate 2020-12-06 00:06:53 +01:00
Andreas Kling
2946a684ef ProtocolServer+LibWeb: Support more detailed HTTP requests
This patch adds the ability for ProtocolServer clients to specify which
HTTP method to use, and also to include an optional HTTP request body.
2020-09-28 11:55:26 +02:00
Benoît Lormeau
f0f6b09acb AK: Remove the ctype adapters and use the actual ctype functions instead
This finally takes care of the kind-of excessive boilerplate code that were the
ctype adapters. On the other hand, I had to link `LibC/ctype.cpp` to the Kernel
(for `AK/JsonParser.cpp` and `AK/Format.cpp`). The previous commit actually makes
sense now: the `string.h` includes in `ctype.{h,cpp}` would require to link more LibC
stuff to the Kernel when it only needs the `_ctype_` array of `ctype.cpp`, and there
wasn't any string stuff used in ctype.
Instead of all this I could have put static derivatives of `is_any_of()` in the
concerned AK files, however that would have meant more boilerplate and workarounds;
so I went for the Kernel approach.
2020-09-27 21:15:25 +02:00
AnotherTest
7e72285049 Userland: Allow unquoted 'filename' values in 'pro' 2020-08-31 23:05:58 +02:00
AnotherTest
861ce62e14 Userland: Improve 'ContentDispositionParser' in 'pro'
This patch just applies a suggestion, making the code more readable.
2020-08-31 23:05:58 +02:00
AnotherTest
cb7526fca0 Userland: Make 'pro' capable of guessing a filename
The whole thing with `pro url > filename` was getting annoying, so let's
just have it support Content-Disposition and guessing from the URL.
2020-08-31 09:14:11 +02:00
Linus Groh
59942edcc0 Userland: Use Core::ArgsParser for 'pro' 2020-08-06 20:41:13 +02:00
Andreas Kling
1678aaa555 ProtocolServer+LibProtocol: Propagate HTTP status codes to clients
Clients now receive HTTP status codes like 200, 404, etc.
Note that a 404 with content is still considered a "successful"
download from ProtocolServer's perspective. It's up to the client
to interpret the status code.

I'm not sure if this is the best API, but it'll work for now.
2020-06-13 22:20:37 +02:00
Andreas Kling
853d900ee8 pro: Show download progress in the terminal window if available :^) 2020-05-30 23:00:35 +02:00
Andreas Kling
eb6e35a1be ProtocolServer: Pass HTTP response headers to the client
We now store the response headers in a download object on the protocol
server side and pass it to the client when finishing up a download.

Response headers are passed as an IPC::Dictionary. :^)
2020-05-03 23:01:58 +02:00
AnotherTest
06cf9d3fb7 ProtocolServer: Implement and handle download progress
Also updates `pro` to display download progress and speed on stderr
2020-05-03 12:59:26 +02:00
Andreas Kling
fc5067afd2 ProtocolServer+LibProtocol: Reject unhandled URLs instead of asserting
StartDownload requests for unhandled protocols (or invalid URLs) will
now refuse to load instead of asserting. A failure code is sent back
to LibProtocol and Protocol::Client::start_download() returns nullptr.

Fixes #1604.
2020-04-04 20:01:36 +02:00
Andreas Kling
d17e23bd27 LibCore: Remove leading C from filenames 2020-02-06 15:04:03 +01:00
Andreas Kling
5b7924b9e7 LibProtocol: Rename namespace LibProtocol => Protocol 2020-02-05 19:13:44 +01:00
Andreas Kling
2d39da5405 LibCore: Put all classes in the Core namespace and remove the leading C
I've been wanting to do this for a long time. It's time we start being
consistent about how this stuff works.

The new convention is:

- "LibFoo" is a userspace library that provides the "Foo" namespace.

That's it :^) This was pretty tedious to convert and I didn't even
start on LibGUI yet. But it's coming up next.
2020-02-02 15:15:30 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Andreas Kling
fc86460134 AK: Move the userspace SharedBuffer from LibC to AK
This always felt out-of-place in LibC.
2020-01-01 18:53:34 +01:00
Andreas Kling
653e61d9cf LibProtocol: Add a Download object so users don't have to manage ID's
LibProtocol::Client::start_download() now gives you a Download object
with convenient hooks (on_finish & on_progress).

Also, the IPC handshake is snuck into the Client constructor, so you
don't need to perform it after instantiating a Client.

This makes using LibProtocol much more pleasant. :^)
2019-11-24 13:22:01 +01:00
Andreas Kling
600c15aa3a pro: Take the URL to download as a command-line argument
Also, don't print anything other than the download payload to stdout.
This gives us a very simple HTTP download utility :^)
2019-11-23 22:16:23 +01:00
Andreas Kling
eb85103271 ProtocolServer: Send the download payload to clients as a shared buffer
The DownloadFinished message from the server now includes a buffer ID
that can be mapped into the client program.

To avoid prematurely destroying the buffer, the server will hang on to
it until the client lets it know that they're all good. That's what the
ProtocolServer::DisownSharedBuffer message is about.

In the future it would be nice if the kernel had a mechanism to allow
passing ownership of a shared buffer along with an IPC message somehow.
2019-11-23 22:11:44 +01:00
Andreas Kling
88c5126fa7 pro: Add a little userland utility for testing ProtocolServer 2019-11-23 21:50:36 +01:00