Skip to content

Conversation

@JunielKatarn
Copy link
Contributor

@JunielKatarn JunielKatarn commented Sep 16, 2022

Backport of #10534

Microsoft Reviewers: Open in CodeFlow

JunielKatarn and others added 11 commits September 16, 2022 15:08
* Skip user agent HTTP header validation

In microsoft#8392, we added logic to skip HTTP header validation for
`User-Agent` in the NetworkingModule. Now that NetworkingModule is being
refactored, we need this change in the new implementation.

This change skips user agent validation in the new networking module.

* Change files
* Added BlobModule and IWSModuleContHandler headers

* Implement Blob module

* Avoid raw self pointer in BlobModule

* Implement WebSocketModule msg processing

* clang format

* Don't return until websocketMessage event is sent

* Define CreateBlobModule()

* Add DEF exports

* Add Blob JS tests

* Add Blob JS tests

* Change files

* yarn lint

* Add overrides

* Register BlobModule in DesktopTestRunner

* Keep ignoring WebSocketBlob test by default

* Add BlobModule to default modules list

* Allow 'blob' responseType in HTTP module

* Ensure React Instance can be accessed when using older versions of react-native

* Emit error message on createFromParts failure

* Remove redundant extra modules in Desktop integration tests

* Declare IWebSocketModuleProxy

* Remove Blob and WS module factories from DLL boundary

* Implement IWebSocketModuleProxy

* clang format

* Update packages.lock

* Use winrt::array_view directly in ResolveMessage

* Define InstanceImpl::m_transitionalModuleProperties

* Include CreateModules.h in projects accessing MSRN.Cxx

* Define WinRT class WebSocketModuleContentHandler

- Have BlobModule constructor register the content handler in transitive
  property bag CxxNativeModule/WebSocketModuleContentHandler

* Have WebSocketModule use IInspectable as props arg

* Use property bag instead of global singletons for blob helpers

* Store blob helpers in prop bag as weak_ptr

* Replace remaining lock_guard<mutex> in BlobModule

* Define IUriHandler, IReqBodyHandler, IRespHandler.

* IHttpResource::SendRequest - add folly::dynamic data arg

* Add data arg to test SendRequest calls

* First implementation for BlobModuleUriHandler

* Remove WebSocketModuleContentHandler WinRT class

* Implement IBlobPersistor, MemoryBlobPersistor

* clang format

* Update yarn.lock

* Update RctRootVieTagGen location

* Implement addNetworkingHandler

* Fix createFromParts buffer persistence

* Drop WebSocketModule s_sharedState in favor of property bag

* Disable back WebSocketBlob test

* Rename iProperties to inspectableProperties

* Pass ReactContext properties to CreateHttpModule in InstanceWin

* Remove WebSocketModule constructor from x86 DLL boundary

* yarn lint

* Update packages.lock

* Make transitional property bag non-member

* Use blobURIScheme wherever possible

* Pass request content as folly::dynaic.

- Pass request ID directly from JavaScript layer.

* Use constexpr for folly indexes

* Implement GetMimeTypeFromUri

* Finish BlobModule handler implementations.

* Remove unused includes

* Ensure HttpModule::m_resource is set

* clang format

* clang format

* Allow blob responseType

* Use winrt::to_hstring instead of Utf8ToUtf16

* Pass inspectableProperties down to WinRTHttpResource

* Implement IHttpModuleProxy via WinRTHttpResource

* Consume URI handler

- IHttpResource
  - Rename SetOnRequest to SetOnRequestSuccess
  - Declare SetOnBlobData to pass complex (non-string) response data

* Consume IRequestBodyHandler

* Consume IResponseHandler

* Ensure properties exist in bag before using value

* Update packages lock

* Add missing call to Modules::SendEvent

* Fix Shared filters

* Rename SetOnBlobData to SetOnData (different args)

* Correctly retrieve blob slices

* Correctly retrieve blob slices

* Clang format

* Update project filters

* Drop BlobModuleUriHandler

* Continue handling requests when not blob-supported

* Add BlobTest

* Update packages.lock.json

* Define FileReaderModule

* Implement FileReaderModule

* Complete BlobTest

* Make IBlobPersistor::ResolveMessage throw std::invalid_argument

* Fail on Content-Encoding parsing even if no error handler

* Remove MIME mappings. Currently unused

* MemoryBlobPersistor::ResolveMessage throw on out of bounds

* lint

* Enable BlobTest by default

* Disable Blob test in CI (may hang)
* update yarn.lock

* Use logical OR to assert HTTP responseType

* Change files
* Implement hard-coded timeout

* Create timeout from JS args

* Timeout only for values greater than 0

* Change files

* Remove variable sendRequestAny

* Remove unused captures
* Use uint8_t const in IBlobPersistor.h

Some versions of clang will not compile when the array_view data for
CryptographicBuffer::CreateFromByteArray is not `uint8_t const`.

This change switches the callsites to use uint8_t const where needed.

* Change files

* Fix Blob test comparison

Co-authored-by: Julio C. Rocha <julio.rocha@microsoft.com>
* Adds missing headers for HttpRequestHeaderCollection

These headers are needed in case alternative PCH are used to compile (e.g.,
with clang BUCK).

* Change files
* Skip user agent HTTP header validation

In microsoft#8392, we added logic to skip HTTP header validation for
`User-Agent` in the NetworkingModule. Now that NetworkingModule is being
refactored, we need this change in the new implementation.

This change skips user agent validation in the new networking module.

* Change files
* Define WinRTHttpResult::CreateRequest

* Use request produced by CreateRequest()

TODO: Have PerformSendRequest receive raw method and uri instead of
HttpRequestMessage.

* Exit if request is not created successfully

* Enabled FullCorsCrossOriginToAnotherCrossOriginRedirectWithPreflightSucceeds

* Single retry

* Add test RedirectPatchSucceeds

* Rename tests to SimpleRedirect<VERB>Succeeds

* Use method and URI intead of full HTTPReqMsg in PerformSendReq

* Move HttpResourceIntegrationTest into workspace

* Add WinInet-based test

* Get request complete variables

* Define RequestContext struct

* Get response content

* Add synchronization logic

* Refer CoreFX reference PR and version

* Disable SimpleRedirectWinInetSucceeds

* Define RedirectHttpFilter

- Meant to be the default internal filter for WinRTHttpResource.

* Use redirect filter for OP and default clients in factory

* Implement RedirectHttpFilter::SendRequestAsync

TODO: Deal with IDS_REQUEST_ALREADY_SENT by making CreateRequest coroutine available to both the resource and filter classes.

* Expose resource as IWinRTHttpRequestFactory

- Allows redir filter to access resource's request factory method.

* Re-arrange resource instantiation in Make factory

* Re-enable disabled Origin Policy tests

* Make redir filter constructors noexcept

* Attempt to implement IHttpBaseProtocolFilter

* Make redir filter implement IHttpBaseProtocolFilter

* Enable inheritance of IHttpBPFilter via unsetting WINRT_LEAN_AND_MEAN

* Implement IHttpBPfilter based on inner filter

* Add RedirHttpFilterUTs class

* Fix comment

* Consume mocks in MockBaseFilter

* Implement mocks in ManualRedirectSucceeds

* Implement manual redir test with coroutines

* Complete [Manual|Automatic]RedirectSucceeds

* Allow setting max redirect # in constructor
- Add test TooManyRedirectsFails

* Add test MaxAllowedRedirectsSucceeds

* Minor requestArgs factoring

* Define and consume IRedirectEventSource

* Add IRedirectEventSource.idl to unit test project

* Update Shared vcx filters

* Partially implement OPFilter::OnRedirecting

* Update Shared filters

* Make OPFilter drop redirection for preflights

* Allow empty string, non-null req content

* Allow non-movable responses in test server (OPIntTests)

* Always clear Http.OmitCredentials rt option

* Update outdated comment

* Removed commented code

* Clean up stale/commented code

* Throw E_INVALIDARG if redirect gets null request handle

* Throw ERROR_HTTP_REDIRECT_FAILED on too many redirects

* Remove/ignore incorrect tests

* clang format

* Change files

* Update packages lock

* Remove Redir filter constructor from DLL boundary

* Drop unused libs/include dirs

* Restore ut project IncludePath

* Remove /*const*/ comments from HTTP mocks

* Explicitly capture `constexpr`

Implicit capture only available starting MSVC 14.3

* Declare redirect counts as size_t

* Update packages.lock.json

* Update packages lock

* Replace IInspectable with WinRT IMap (request props) in CreateRequest

* Make TaintedOrigin a direct request property.

The `RequestArgs` struct should not hold Origin POlicy specific data.

* clang format

* Fix compilation of filter and resource in MSRN

* Rename local variables

* Fix relative include of WinRTTypes

* Simplify redirect count tests

* Propagate isTimeout to JS layer

* Comment alternative HRESULTs for timeout

* Address feedback for internal MIDL type

* Update packages lock

* Use std::stol to parse Content-Length

* Use constexpr for default max redirects

* Drop WinRT/Http/Filters header from PCH

- This prevents including the header with WINRT_LEAN_AND_MEAN macro conflict.
- Only DevSupportManager required it. Performance loss is negligible.

* Add interface IRedirectEventSource2

* Remove IDL IRedirectEventSource

* Rename IRedirectEventSource2 to IRedirectEventSource

* Revert packages lock

* Remove stale IDL reference

* Throw on RedirectHttpFilter::AllowUI
@JunielKatarn JunielKatarn requested review from a team as code owners September 16, 2022 22:55
JunielKatarn and others added 6 commits September 16, 2022 16:30
* Update packages.lock.json

* Update packages.lock.json

* Add Shared project to ReactUWPTestApp solution

* RNTesterApp.csproj formatting

* Enable Blob module in UWP

* Change files

* Update packages.lock.json

* Use context property bag for runtime options in MSRN

* Remove unused options header

* Revert ReactUWPTestApp.sln

* Update packages.lock.json

* Update packages.lock.json

* Use namespace in monolith HTTP module property
@JunielKatarn JunielKatarn merged commit 3d88ad5 into microsoft:0.69-stable Sep 17, 2022
@JunielKatarn JunielKatarn deleted the cors-redir-69 branch September 17, 2022 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants