Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

RequestInit and Request cf properties are different #15

Closed
AngusMorton opened this issue Apr 8, 2020 · 2 comments · Fixed by #18
Closed

RequestInit and Request cf properties are different #15

AngusMorton opened this issue Apr 8, 2020 · 2 comments · Fixed by #18
Milestone

Comments

@AngusMorton
Copy link

RequestInit and Request cf properties are different, this makes using patterns like return new Request(parsedUrl.toString(), request) impossible because Request.cf is not structurally identical to RequestInit.cf.

I suggest we converge on a common cf type for both Request and RequestInit to support the above pattern.

@ispivey
Copy link
Contributor

ispivey commented May 9, 2020

I just ran in to this as well!

@ispivey
Copy link
Contributor

ispivey commented May 9, 2020

I'll take a shot at reconciling these this week.

ispivey added a commit to ispivey/workers-types that referenced this issue May 10, 2020
Fixes cloudflare#15.

There are two distinct cf objects serves associated with a Request:
1. On an eyeball Request attached to a FetchEvent, the cf property
   contains metadata about the request, provided by Cloudflare's
   edge.
2. As part of a dictionary of configuration passed to the Request
   constructor, the cf property allows a user to control certain
   Cloudflare functionality that can be applied to said Request,
   like image resizing.

While those two things are both objects in a dictionary with the
key "cf", they are otherwise distinct.

This change makes these two types explicitly different, and
specifies that a Request constructor's RequestInit dict can have
a "cf" property that is either (1) or (2).

Previously, passing a Request object as the `init` arg to the
Request constructor failed, because an eyeball request's cf prop
did not have the same shape as (2).
ispivey added a commit to ispivey/workers-types that referenced this issue May 10, 2020
Fixes cloudflare#15.

There are two distinct cf objects serves associated with a Request:
1. On an eyeball Request attached to a FetchEvent, the cf property
   contains metadata about the request, provided by Cloudflare's
   edge.
2. As part of a dictionary of configuration passed to the Request
   constructor, the cf property allows a user to control certain
   Cloudflare functionality that can be applied to said Request,
   like image resizing.

While those two things are both objects in a dictionary with the
key "cf", they are otherwise distinct.

This change makes these two types explicitly different, and
specifies that a Request constructor's RequestInit dict can have
a "cf" property that is either (1) or (2).

Previously, passing a Request object as the `init` arg to the
Request constructor failed, because an eyeball request's cf prop
did not have the same shape as (2).
@ispivey ispivey added this to the Release 1.0.10 milestone May 14, 2020
ispivey added a commit that referenced this issue May 14, 2020
Fixes #15.

There are two distinct cf objects serves associated with a Request:
1. On an eyeball Request attached to a FetchEvent, the cf property
   contains metadata about the request, provided by Cloudflare's
   edge.
2. As part of a dictionary of configuration passed to the Request
   constructor, the cf property allows a user to control certain
   Cloudflare functionality that can be applied to said Request,
   like image resizing.

While those two things are both objects in a dictionary with the
key "cf", they are otherwise distinct.

This change makes these two types explicitly different, and
specifies that a Request constructor's RequestInit dict can have
a "cf" property that is either (1) or (2).

Previously, passing a Request object as the `init` arg to the
Request constructor failed, because an eyeball request's cf prop
did not have the same shape as (2).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants