rustypaste-cli icon indicating copy to clipboard operation
rustypaste-cli copied to clipboard

ureq update to 3.0.8

Open tessus opened this issue 9 months ago • 0 comments

Discussed in https://github.com/orhun/rustypaste-cli/discussions/178

Originally posted by tessus March 8, 2025 Due to the errors in the CI pipeline for the recent PR (updating ring), I looked into upgrading ureq.

While most of the tasks are trivial, error handling seems worse than before.

e.g.

match ureq::get("http://mypage.example.com/").call() {
    Ok(response) => { /* it worked */},
    Err(Error::Status(code, response)) => {
        /* the server returned an unexpected status
           code (such as 400, 500 etc) */
    }
    Err(_) => { /* some kind of io/transport error */ }
}

turned into:

match ureq::get("http://mypage.example.com/").call() {
    Ok(response) => { /* it worked */},
    Err(Error::StatusCode(code)) => {
        /* the server returned an unexpected status
           code (such as 400, 500 etc) */
    }
    Err(_) => { /* some kind of io/transport/etc error */ }
}

So how am I supposed to print the response message in case of an error as we are currently doing like so: https://github.com/orhun/rustypaste-cli/blob/master/src/upload.rs#L205-L209

With these issues and the fact that multipart is no longer maintained, I am not quite sure the current code is properly maintainable. Switching to a different http client (and which one to choose) might also turn out to be a nightmare. On the other side, I believe ureq might get support for multipart in the future.

Any ideas or suggestions?

The solution is described here: https://github.com/algesten/ureq/issues/997#issuecomment-2658534447

tessus avatar Mar 12 '25 20:03 tessus