Skip to content

Commit 589a43a

Browse files
committed
Merge commit '7a3c9a2fd29bdd89706b4a8a3f362fa48edd0e2c' into jun/do/alarm-invocation-detail
2 parents c92e263 + 7a3c9a2 commit 589a43a

34 files changed

+253
-186
lines changed

src/content/docs/d1/examples/query-d1-from-python-workers.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ The value of `binding` is how you will refer to your database from within your W
8181
To create a Python Worker, create an empty file at `src/entry.py`, matching the value of `main` in your Wrangler file with the contents below:
8282

8383
```python
84-
from js import Response
84+
from workers import Response
8585

8686
async def on_fetch(request, env):
8787
# Do anything else you'd like on request here!

src/content/docs/reference-architecture/architectures/load-balancing.mdx

Lines changed: 20 additions & 17 deletions
Large diffs are not rendered by default.

src/content/docs/rules/page-rules/reference/settings.mdx

Lines changed: 4 additions & 9 deletions
Large diffs are not rendered by default.

src/content/docs/rules/reference/troubleshooting.mdx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ description: Review common troubleshooting scenarios for Rules features.
1111

1212
import { Example, Render } from "~/components";
1313

14+
## Interaction between redirects and other Cloudflare products
15+
16+
Your redirects may interfere with Cloudflare products and features such as challenges. Consider excluding the [`/cdn-cgi/*` URI path](/fundamentals/reference/cdn-cgi-endpoint/) in your rule expression to avoid issues. Alternatively, you may exclude only a sub-path such as `/cdn-cgi/challenge-platform/*` to avoid issues with specific features (in this example, [Cloudflare challenges](#interaction-between-cloudflare-challenges-and-rules-features)).
17+
18+
You may also want to exclude the `/.well-known/*` URL path used by several validation services. Refer to [Interaction between redirects and verification procedures like HTTP DCV](#interaction-between-redirects-and-verification-procedures-like-http-dcv) for more information.
19+
1420
## Interaction between Cloudflare challenges and Rules features
1521

1622
If you are issuing a [challenge](/waf/reference/cloudflare-challenges/) for a given URI path that has one or more Rules features enabled, you should exclude URI paths starting with `/cdn-cgi/challenge-platform/` in your rule expressions to avoid challenge loops.
@@ -21,11 +27,11 @@ For example, define a compound expression for your rule using the `and` operator
2127
<OTHER_RULE_CONDITIONS> and not starts_with(http.request.uri, "/cdn-cgi/challenge-platform/")
2228
```
2329

24-
## HTTP DCV and redirects
30+
## Interaction between redirects and verification procedures like HTTP DCV
2531

26-
<Render file="dcv-definition" product="ssl" />
32+
Paths used in validation procedures such as custom hostname verification (Cloudflare for SaaS), [Pages domain validation](/pages/configuration/debugging-pages/), or [HTTP domain control validation (DCV)](/ssl/edge-certificates/changing-dcv-method/methods/http/) may be affected by redirects.
2733

28-
If you are using [HTTP DCV](/ssl/edge-certificates/changing-dcv-method/methods/http/) and also have [Single Redirects](/rules/url-forwarding/single-redirects/) set up in your zone, consider excluding the `/.well-known/*` path from your rule to avoid DCV issues. For details and other resources refer to the [SSL/TLS documentation](/ssl/edge-certificates/changing-dcv-method/).
34+
Consider excluding the `/.well-known/*` URI path from your rule to avoid issues.
2935

3036
## Content-Length header removed from response
3137

src/content/docs/terraform/additional-configurations/ddos-managed-rulesets.mdx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ For more information on deploying and configuring rulesets using the Rulesets AP
3535

3636
## Example: Configure HTTP DDoS Attack Protection
3737

38-
This example configures the [HTTP DDoS Attack Protection](/ddos-protection/managed-rulesets/http/) managed ruleset for a zone using Terraform, changing the sensitivity level of rule with ID <RuleID id="fdfdac75430c4c47a959592f0aa5e68a" /> to `low`.
38+
This example configures the [HTTP DDoS Attack Protection](/ddos-protection/managed-rulesets/http/) managed ruleset for a zone using Terraform.
3939

4040
<Render file="v4-code-snippets" />
4141

@@ -48,21 +48,36 @@ resource "cloudflare_ruleset" "zone_level_http_ddos_config" {
4848
phase = "ddos_l7"
4949
5050
rules {
51-
ref = "override_l7_ddos_ruleset_all"
52-
description = "Override the HTTP DDoS Attack Protection managed ruleset"
53-
expression = "true"
54-
action = "execute"
51+
action = "execute"
5552
action_parameters {
5653
# Cloudflare L7 DDoS Attack Protection Ruleset
5754
id = "4d21379b4f9f4bb088e0729962c8b3cf"
5855
overrides {
56+
action = "block"
57+
sensitivity_level = "default"
5958
rules {
60-
# Rule: HTTP requests with unusual HTTP headers or URI path (signature #11).
61-
id = "fdfdac75430c4c47a959592f0aa5e68a"
62-
sensitivity_level = "low"
59+
# Adaptive DDoS Protection based on Locations (Available only to Enterprise zones with Advanced DDoS service)
60+
id = "a8c6333711ff4b0a81371d1c444be2c3"
61+
sensitivity_level = "default"
62+
action = "managed_challenge"
63+
}
64+
rules {
65+
# Adaptive DDoS Protection based on User-Agents (Available only to Enterprise zones with Advanced DDoS service)
66+
id = "7709d496081e458899c1e3a6e4fe8e55"
67+
sensitivity_level = "default"
68+
action = "managed_challenge"
69+
}
70+
rules {
71+
# HTTP requests causing a high number of origin errors.
72+
id = "dd42da7baabe4e518eaf11c393596a9d"
73+
sensitivity_level = "default"
74+
action = "managed_challenge"
6375
}
6476
}
6577
}
78+
expression = "true"
79+
description = "Zone-wide HTTP DDoS Override"
80+
enabled = true
6681
}
6782
}
6883
```

src/content/docs/workers/examples/103-early-hints.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default {
111111

112112
```py
113113
import re
114-
from js import Response, Headers
114+
from workers import Response
115115

116116
CSS = "body { color: red; }"
117117
HTML = """
@@ -129,11 +129,11 @@ HTML = """
129129
"""
130130
def on_fetch(request):
131131
if re.search("test.css", request.url):
132-
headers = Headers.new({"content-type": "text/css"}.items())
133-
return Response.new(CSS, headers=headers)
132+
headers = {"content-type": "text/css"}
133+
return Response(CSS, headers=headers)
134134
else:
135-
headers = Headers.new({"content-type": "text/html","link": "</test.css>; rel=preload; as=style"}.items())
136-
return Response.new(HTML, headers=headers)
135+
headers = {"content-type": "text/html","link": "</test.css>; rel=preload; as=style"}
136+
return Response(HTML, headers=headers)
137137
```
138138

139139
</TabItem> </Tabs>

src/content/docs/workers/examples/ab-testing.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default {
100100
```py
101101
import random
102102
from urllib.parse import urlparse, urlunparse
103-
from js import Response, Headers, fetch
103+
from workers import Response, fetch
104104

105105
NAME = "myExampleWorkersABTest"
106106

@@ -132,8 +132,7 @@ async def on_fetch(request):
132132
res = await fetch(urlunparse(url))
133133
headers = dict(res.headers)
134134
headers["Set-Cookie"] = f'{NAME}={group}; path=/'
135-
headers = Headers.new(headers.items())
136-
return Response.new(res.body, headers=headers)
135+
return Response(res.body, headers=headers)
137136

138137
return fetch(urlunparse(url))
139138
```

src/content/docs/workers/examples/accessing-the-cloudflare-object.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ export default {
6060

6161
```py
6262
import json
63-
from js import Response, Headers, JSON
63+
from workers import Response
64+
from js import JSON
6465

6566
def on_fetch(request):
6667
error = json.dumps({ "error": "The `cf` object is not available inside the preview." })
6768
data = request.cf if request.cf is not None else error
68-
headers = Headers.new({"content-type":"application/json"}.items())
69-
return Response.new(JSON.stringify(data, None, 2), headers=headers)
69+
headers = {"content-type":"application/json"}
70+
return Response(JSON.stringify(data, None, 2), headers=headers)
7071
```
7172

7273
</TabItem> </Tabs>

src/content/docs/workers/examples/aggregate-requests.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,21 @@ export default {
6161
</TabItem> <TabItem label="Python" icon="seti:python">
6262

6363
```py
64-
from js import Response, fetch, Headers, JSON, Promise
64+
from workers import Response, fetch
65+
import asyncio
66+
import json
6567

6668
async def on_fetch(request):
6769
# some_host is set up to return JSON responses
6870
some_host = "https://jsonplaceholder.typicode.com"
6971
url1 = some_host + "/todos/1"
7072
url2 = some_host + "/todos/2"
7173

72-
responses = await Promise.all([fetch(url1), fetch(url2)])
73-
results = await Promise.all(map(lambda r: r.json(), responses))
74+
responses = await asyncio.gather(fetch(url1), fetch(url2))
75+
results = await asyncio.gather(*(r.json() for r in responses))
7476

75-
headers = Headers.new({"content-type": "application/json;charset=UTF-8"}.items())
76-
return Response.new(JSON.stringify(results), headers=headers)
77+
headers = {"content-type": "application/json;charset=UTF-8"}
78+
return Response.json(results, headers=headers)
7779
```
7880

7981
</TabItem> </Tabs>

src/content/docs/workers/examples/alter-headers.mdx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,27 @@ export default {
8080
</TabItem> <TabItem label="Python" icon="seti:python">
8181

8282
```py
83-
from js import Response, fetch
83+
from workers import Response, fetch
8484

8585
async def on_fetch(request):
8686
response = await fetch("https://example.com")
8787

88-
# Clone the response so that it's no longer immutable
89-
new_response = Response.new(response.body, response)
88+
# Grab the response headers so they can be modified
89+
new_headers = response.headers
9090

9191
# Add a custom header with a value
92-
new_response.headers.append(
93-
"x-workers-hello",
94-
"Hello from Cloudflare Workers"
95-
)
96-
92+
new_headers["x-workers-hello"] = "Hello from Cloudflare Workers"
93+
9794
# Delete headers
98-
new_response.headers.delete("x-header-to-delete")
99-
new_response.headers.delete("x-header2-to-delete")
95+
if "x-header-to-delete" in new_headers:
96+
del new_headers["x-header-to-delete"]
97+
if "x-header2-to-delete" in new_headers:
98+
del new_headers["x-header2-to-delete"]
10099

101100
# Adjust the value for an existing header
102-
new_response.headers.set("x-header-to-change", "NewValue")
101+
new_headers["x-header-to-change"] = "NewValue"
103102

104-
return new_response
103+
return Response(response.body, headers=new_headers)
105104
```
106105

107106
</TabItem> </Tabs>

0 commit comments

Comments
 (0)