Skip to content

Commit e22a936

Browse files
committed
update readme
1 parent c04cebc commit e22a936

File tree

1 file changed

+87
-8
lines changed

1 file changed

+87
-8
lines changed

README.md

Lines changed: 87 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,93 @@
1-
# httsleep
1+
# 😴 httsleep
22

3-
It's a simple service for producing delayed http calls.
3+
A simple service for producing delayed HTTP responses. Perfect for testing how your applications handle slow network requests, timeouts, and loading states.
44

5-
Can for example be used to test asynchronous scenarios where you need to figure out how components behave when requests (for example ajax requests) take longer than in your normal environment and Chrome network throttling just is not enough.
6-
It can also be useful to test timeout behavior of client libraries.
5+
## Why httsleep?
76

8-
You only need to add the number of seconds, you'd like a request to wait before it is answered, to an url. Just like: [ https://httsleep.herokuapp.com/3/](https://httsleep.herokuapp.com/3/)
7+
- Test how your UI handles slow API responses (loading spinners, skeleton screens)
8+
- Verify timeout behavior in HTTP client libraries
9+
- Simulate network latency that Chrome DevTools throttling can't replicate
10+
- Test async scenarios where requests take longer than your normal environment
911

10-
Can also be used to redirect: https://httsleep.herokuapp.com/3/?redirectUrl=https://httpbin.org/headers
12+
## Live Service
1113

12-
Or proxy: https://httsleep.herokuapp.com/3/?proxyUrl=https://httpbin.org/headers
14+
httsleep is available at: **https://httsleep.r10r.dev**
1315

14-
The maximun delay currently is 120 seconds.
16+
---
17+
18+
## Features
19+
20+
### ⏱️ Simple Delay
21+
22+
Returns a `200 OK` response after waiting the specified number of seconds.
23+
24+
**Pattern:** `/:seconds`
25+
26+
**Examples:**
27+
28+
```
29+
https://httsleep.r10r.dev/3 # Wait 3 seconds
30+
https://httsleep.r10r.dev/0.5 # Wait 500ms
31+
https://httsleep.r10r.dev/10 # Wait 10 seconds
32+
```
33+
34+
**Usage:**
35+
36+
```javascript
37+
// Test a 5-second timeout
38+
fetch("https://httsleep.r10r.dev/5")
39+
.then((response) => console.log("Response received after 5 seconds"))
40+
.catch((error) => console.log("Request failed or timed out"));
41+
```
42+
43+
---
44+
45+
### ↪️ Delayed Redirect
46+
47+
Redirects to the specified URL after waiting. Returns a `301` redirect response.
48+
49+
**Pattern:** `/:seconds?redirectUrl=:url`
50+
51+
**Examples:**
52+
53+
```
54+
https://httsleep.r10r.dev/3?redirectUrl=https://httpbin.org/headers
55+
https://httsleep.r10r.dev/2?redirectUrl=https://example.com
56+
```
57+
58+
**Usage:**
59+
60+
```javascript
61+
// Test redirect handling with network latency
62+
fetch("https://httsleep.r10r.dev/2?redirectUrl=https://api.example.com/data", {
63+
redirect: "follow",
64+
})
65+
.then((response) => response.json())
66+
.then((data) => console.log(data));
67+
```
68+
69+
---
70+
71+
### 🔀 Delayed Proxy
72+
73+
Fetches a URL and returns its response after the delay. The original response headers and status code are preserved.
74+
75+
**Pattern:** `/:seconds?proxyUrl=:url`
76+
77+
**Examples:**
78+
79+
```
80+
https://httsleep.r10r.dev/3?proxyUrl=https://httpbin.org/json
81+
https://httsleep.r10r.dev/5?proxyUrl=https://api.github.com/users/octocat
82+
```
83+
84+
**Usage:**
85+
86+
```javascript
87+
// Simulate a slow API response with real data
88+
fetch(
89+
"https://httsleep.r10r.dev/3?proxyUrl=https://jsonplaceholder.typicode.com/posts/1"
90+
)
91+
.then((response) => response.json())
92+
.then((data) => console.log("Received after 3 seconds:", data));
93+
```

0 commit comments

Comments
 (0)