Skip to content

Commit d6085e2

Browse files
committed
Note that 307 redirects aren't followed in the docs
1 parent 47958c3 commit d6085e2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/agent.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,24 @@ impl AgentBuilder {
408408
///
409409
/// If the redirect count hits this limit (and it's > 0), TooManyRedirects is returned.
410410
///
411+
/// WARNING: for 307 and 308 redirects, this value is ignored for methods that have a body.
412+
/// You must handle 307 redirects yourself when sending a PUT, POST, PATCH, or DELETE request.
413+
///
411414
/// ```
412415
/// # fn main() -> Result<(), ureq::Error> {
413416
/// # ureq::is_test(true);
414417
/// let result = ureq::builder()
415418
/// .redirects(1)
416419
/// .build()
417-
/// .get("http://httpbin.org/redirect/3")
418-
/// .call();
420+
/// .get("http://httpbin.org/status/301")
421+
/// .error_on_non_2xx(false)
422+
/// .call()?;
423+
/// assert_ne!(result.status(), 301);
424+
///
425+
/// let result = ureq::put("http://httpbin.org/status/307")
426+
/// .error_on_non_2xx(false)
427+
/// .send_bytes(b"some data")?;
428+
/// assert_eq!(result.status(), 308);
419429
/// # Ok(())
420430
/// # }
421431
/// ```

0 commit comments

Comments
 (0)