-
Notifications
You must be signed in to change notification settings - Fork 491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Providing files from memory #306
Comments
Hi @nikeee, test.hurl
|
I implemented this in a fork, using the vfs crate. You can see the diff here: master...nikeee:master There is one failing test, though:
This originates from
Is this something that would align with the project goals? If not, I'd maintain this in a separate fork. |
Hi @nikeee, |
Since #284 is resolved and we'd be able to use Hurl as a library: |
Hi @nikeee you can create a request body that uses memory by building an instance of pub enum Bytes {
Json(json::Value),
Xml(String),
MultilineString(MultilineString),
OnelineString(Template),
Base64(Base64),
File(File),
Hex(Hex),
} For a memory file, you can use the pub struct Hex {
pub space0: Whitespace,
pub value: Vec<u8>,
pub encoded: String,
pub space1: Whitespace,
} Or use For the moment, we're not going to improve this use case. The core focus of the project is:
The aim is to have an excellent CLI tool "à la" curl. The fact that one can use Hurl as a library is a very nice bonus, and we'll try to facilitate it. But our focus is the CLI and not Hurl as a crate. I hope you understand we're trying to stay focused on these features. In any case, I can assist you with sample code to how to forge a request by code, which can be done with the current version (1.8.0). |
I'll take a look at that, thank you for this approach. :)
And that's great! Keep doing awesome stuff! |
If I'm getting the docs right, it seems that in requestes referencing files, they would be read from disk (relative to
context_dir
I guess).Is it possible to provide files to the hurl runner that are read from program memory instead from the disk? This would probably be useful when doing #233.
Maybe something like this?
FileProvider
could be a trait that provides methods to read a file, retrieving the content-length etc.When it also provides writing abilities, it could be used to capture files from requests in-memory without writing them to disk, possibly adding a CLI option to retain captured files in memory.
Instead of the
FileSource
enum, a plainFileProvider
could suffice, as one implementing IO access for thecontext_dir
could be created on the fly infn execute
.As I'm not that familiar with rust, there might also be an existing trait for this kind of virtual file system.
Looking at the source where the files are included, referencing in-memory data, as it seems that the parameters are passed as classic cURL CLI params:
hurl/packages/hurl/src/http/request_spec.rs
Lines 180 to 210 in e59e2ac
The text was updated successfully, but these errors were encountered: