Keep `ureq::Agent` for native clients

Open
#4 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
api

Research direction

Start by reading the existing fetch entry point and the native-client integration around ureq::Agent; no source files or tests are named in the issue. Trace how requests are created across native and WASM targets, then define how an Agent preserves cookies between calls while keeping the current fetch API usable, with tests covering repeated requests and both target paths.

Written by the indexing model from the issue text.

Description

I love the simple API of this crate! It can be useful if ehttp supports saving cookies, such as login function. Currently, the "agent" (ureq::Agent type) is not continuous between each request.

A cross-platform and object-oriented example might look like this:

pub struct Agent {
    #[cfg(not(target_arch = "wasm32"))]
    agent: ureq::Agent,
}

// save the session if we need (compatible syntax)
let session = Agent::new();
session.fetch(req, |r| match r {
    Ok(r) if r.ok => alert("Login successfully!"),
    _ => alert("Login failed!"),
});

// original "fetch" function
fetch(req, |r| match r {
    Ok(r) if r.ok => alert("Login successfully!"),
    _ => alert("Login failed!"),
});
Dominant language
Rust
Stars
404
Forks
38
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from emilk/ehttp

All issues in emilk/ehttp

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.