Skip to content

Conversation

@JunielKatarn
Copy link
Contributor

@JunielKatarn JunielKatarn commented Jun 28, 2023

Description

Define an HTTP module based on the modern REACT_MODULE type system.

Before merging

  • Address TODO comments (including DEF and autogenerated sources cleanup)
  • Validate JavaScript changes by static analysis
  • Revert module.g.cpp. The issues appear to be local-only.

Type of Change

  • New feature (non-breaking change which adds functionality)

Why

In the long term, we want all modules to be REACT_MODULE.

What

  • Defined Microsoft::React::Modules::HttpTurboModule.
    Note, the TurboModule variant is currently not enabled. This PR only implements it.
  • Updated Microsoft::React::Networking::IHttpResource
    • SendRequest: Make argument data winrt::Microsoft::ReactNative::JSValueObject &&
    • SetOnData: Make argument handler std::function<void(int64_t requestId, winrt::Microsoft::ReactNative::JSValueObject &&responseData)>
  • Migrated internal types related to HTTP, WebSockets and Blob from folly::dynamic to msrn::JSValueObject
    • IResponseHandler
    • IUriHandler
    • IRequestBodyHandler
  • Drops forked implementation of RCTNetworking.
    • Imports iOS HTTP spec and manages request counter internally (C++ module member variable).

Addresses #11790

Screenshots

Add any relevant screen captures here from before or after your changes.

Testing

  • All active tests from React.Windows.Desktop.IntegrationTests (locally).
Microsoft Reviewers: codeflow:open?pullrequest=#11825

@JunielKatarn JunielKatarn requested a review from acoates-ms June 30, 2023 00:40
@JunielKatarn JunielKatarn merged commit 873bbb0 into microsoft:main Jul 3, 2023
@JunielKatarn JunielKatarn deleted the turbomod-http branch July 3, 2023 18:44
JunielKatarn added a commit to jurocha-ms/react-native-windows that referenced this pull request Jul 14, 2023
* Declare TurboModule

* Generate NativeNetworkingWindows spec

* Define HttpTurboModule

* Begin resource setup

* Initialize: Up to SetOnData

* Define wchar_t event names

* Migrate IRequestBodyHandler to JSValue

IMPORTANT: Migrate and fix RequestArgs::Data

* Migrate IResponseHandler to JSValue

* Rename m_onDataDynamic as m_onDataObject

* Implement Microsoft::React::Modules::ToJSValue

* Migrate IHttpResource to JSValue

* Fix Playground flavors ordering

* Finish implementing Initialize

* Define ToDynamic

* Change files

* Revert module.g.cpp

* Revert "Revert module.g.cpp"

This reverts commit 2f6c88a.

* Define target SetCppWinRTReferences

* clang format

* Revert temporary symbol exports

* Fix RedirectHttpFilterUnitTest import order

* Preserve include ordering in RedirectHttpFilterUnitTest.cpp

* Fix JSValueArray list constructor

* Drop RCTNetworkingNative in favor of NativeNetworkingWindows

* Add NativeNetworkingWindows to overrides

* Fix overrides.json newline

* Desktop int. tests: set RN_PLATFORM to win32

* Use iterator to lookup content types

* Revert module.g.cpp to main

* Use iterator for ToRequestBody content type

* Drop namespace from JSValueObject usage

* Finish HttpTurboModule

* clang format

* Use iOS HTTP spec

* Use DynamicReader and DynamicWriter for folly conversions

* Revert overrides.json

* Don't add newline to overrides.json

* Make RCTNetworking.windows.js a copy of RCTNetworking.ios.js

* Override upgrade
JunielKatarn added a commit to jurocha-ms/react-native-windows that referenced this pull request Jul 14, 2023
* Declare TurboModule

* Generate NativeNetworkingWindows spec

* Define HttpTurboModule

* Begin resource setup

* Initialize: Up to SetOnData

* Define wchar_t event names

* Migrate IRequestBodyHandler to JSValue

IMPORTANT: Migrate and fix RequestArgs::Data

* Migrate IResponseHandler to JSValue

* Rename m_onDataDynamic as m_onDataObject

* Implement Microsoft::React::Modules::ToJSValue

* Migrate IHttpResource to JSValue

* Fix Playground flavors ordering

* Finish implementing Initialize

* Define ToDynamic

* Change files

* Revert module.g.cpp

* Revert "Revert module.g.cpp"

This reverts commit 2f6c88a.

* Define target SetCppWinRTReferences

* clang format

* Revert temporary symbol exports

* Fix RedirectHttpFilterUnitTest import order

* Preserve include ordering in RedirectHttpFilterUnitTest.cpp

* Fix JSValueArray list constructor

* Drop RCTNetworkingNative in favor of NativeNetworkingWindows

* Add NativeNetworkingWindows to overrides

* Fix overrides.json newline

* Desktop int. tests: set RN_PLATFORM to win32

* Use iterator to lookup content types

* Revert module.g.cpp to main

* Use iterator for ToRequestBody content type

* Drop namespace from JSValueObject usage

* Finish HttpTurboModule

* clang format

* Use iOS HTTP spec

* Use DynamicReader and DynamicWriter for folly conversions

* Revert overrides.json

* Don't add newline to overrides.json

* Make RCTNetworking.windows.js a copy of RCTNetworking.ios.js

* Override upgrade
JunielKatarn added a commit that referenced this pull request Jul 18, 2023
* Use Boost GUID generator (#11470)

* Update package lock

* Use Boost UUID library

* Change files

* Remove GuidHelper import

* Bump C++ Windows Version macros to Windows 10 (#11516)

* Bump default _WIN32_WINNT_VERSION

* Change files

* Remove unused Beast-dependent code (#11517)

* Remove unused Beast production code

* Change files

* clang format

---------

Co-authored-by: Andrew Coates <30809111+acoates-ms@users.noreply.github.com>

* Define FileReader turbo module (#11789)

* Declare FileReaderTurboModule

* Declare m_blobPersistor

* Use msrn namespace alias in FileReader module

* json lock

* Update lock files

* config

* Implement ReadAsDataUrl

* Define ReadAsText

* Define FileReaderResource

* Move persistor from module into resource

* Rename module name name

* Add using ModuleSpec

* clang format

* Change files

* Define WebSocket TurboModule (#11802)

* Add WSTurboModule.h

* Implement CreateResource and MSRN SendEvent

* Define IWebSocketModuleContentHandler::ProcessMessage with JSValueObject

* Complete WebSocketTurboModule::CreateResource

* Complete WebSocketTurboModule::Connect

* Implement close, send, sendBinary and ping

* Include NativeWebSocketModuleSpec

* Make Close spec-compliant

* Add spec-compliant method stubs

* Make remaining existing methods spec-compliant

* Move NOOP Add/RemoveListeners implementation into source file

* clang format

* Use double as keys for m_resourceMap

* Change files

* Define HTTP TurboModule (#11825)

* Declare TurboModule

* Generate NativeNetworkingWindows spec

* Define HttpTurboModule

* Begin resource setup

* Initialize: Up to SetOnData

* Define wchar_t event names

* Migrate IRequestBodyHandler to JSValue

IMPORTANT: Migrate and fix RequestArgs::Data

* Migrate IResponseHandler to JSValue

* Rename m_onDataDynamic as m_onDataObject

* Implement Microsoft::React::Modules::ToJSValue

* Migrate IHttpResource to JSValue

* Fix Playground flavors ordering

* Finish implementing Initialize

* Define ToDynamic

* Change files

* Revert module.g.cpp

* Revert "Revert module.g.cpp"

This reverts commit 2f6c88a.

* Define target SetCppWinRTReferences

* clang format

* Revert temporary symbol exports

* Fix RedirectHttpFilterUnitTest import order

* Preserve include ordering in RedirectHttpFilterUnitTest.cpp

* Fix JSValueArray list constructor

* Drop RCTNetworkingNative in favor of NativeNetworkingWindows

* Add NativeNetworkingWindows to overrides

* Fix overrides.json newline

* Desktop int. tests: set RN_PLATFORM to win32

* Use iterator to lookup content types

* Revert module.g.cpp to main

* Use iterator for ToRequestBody content type

* Drop namespace from JSValueObject usage

* Finish HttpTurboModule

* clang format

* Use iOS HTTP spec

* Use DynamicReader and DynamicWriter for folly conversions

* Revert overrides.json

* Don't add newline to overrides.json

* Make RCTNetworking.windows.js a copy of RCTNetworking.ios.js

* Override upgrade

* Default IncludeFabricInterface to true (#11835)

* Default IncludeFabricInterface to true

* Change files

* Remove IncludeFabricInterface from ExperimentalFeatures

* Define Blob TurboModule (#11842)

* REVERT: remove CompositionView exports

* Declare BlobTurboModule

* Revert "REVERT: remove CompositionView exports"

This reverts commit 1ba874e.

* Define BlobTurboModule

* Declare IBlobResource

* Define DefaultBlobResource

* Define BlobCallbacks

* Migrate BlobWebSocketModuleContentHandler

* Pass needed args to DefaultBlobResource

* Define IBlobResource +/- network handlers

* Implement BlobModule using IBlobResource

* Fix GetConstants ownership

* Change files

* Set up error callback!

* clang format

* Remove BlobModule::SharedState

* Clean up includes and usings

* Remove ProcessMessage folly variant

* Remove folly:dynamic references

* Define IBlobResource::FieldNames

* Move IBlobPersistor out of Modules/

* Remove TODO comments

* clang format

* Add missing include to DefaultBlobResource

* Change multi_threaded_map to single_threaded_map in WinRTHttpResource (#11604)

* Change multi_threaded_map to single_threaded_map in WinRTHttpResource

* Change files

* Fix fetch failing with certain custom user agents (#11775)

* Fix fetch failing with certain custom user agents

* Change files

* Use TurboModules for networking in MSRN (#11867)

* Update packages.json

* Define GetHttpTurboModuleName

* Update packages.json

* Define GetHttpModuleProvider

* Define other netwk modules provider methods

* Register networking turbomodules

* Change files

* clang format

* Uncomment MSRN forward declarations

* Remove cntPtr.h include

* Remove CoreNativeModules

* Revert packages.lock.json

* Remove change files

* Change files

* Revert lock files

* Use correct data types in FileReaderTurboModule::ReadAs* (#11902)

* Use ReadAs* data argument as JSValueObject

* Change files

* Remove change files

---------

Co-authored-by: Andrew Coates <30809111+acoates-ms@users.noreply.github.com>
Co-authored-by: Liron Yahdav <lyahdav@users.noreply.github.com>
JunielKatarn added a commit that referenced this pull request Jul 18, 2023
* Implement HTTP incremental updates (#10933)

* Declare remaining HTTP module event names

* Set Progress handler

* More debug data

* Update AutolinkedNativeModules.g

* Define IHttpResource::SetOnIncrementalData

* Set up and invoke OnIncrementalData

* Clean up Progress functor

* Handle didReceiveNetworkDataProgress event

- Define IHttpResource::SetOnDataProgress

* Default segment size to 8MB

* Define IHttpResource::SetOnResponseComplete

- Separates request completion event from non-incremental data reception event.

* Revert playground-win32 generated files

* Change files

* Address feedback

* Added docs for IHttpResource methods

* Test Access-Control-Request-Headers (#11031)

* Add test ValidatePreflightResponseMainAndContentHeadersSucceeds
* Allow resetting static origin

* Allow disabling static graph restore under VS (#11186)

* Drop RestoreUseStaticGraphEvaluation

* emtpy

* Change files

* Revert unrelated files

* Revert to main

* Condition restore graph to DisableRestoreUseStaticGraphEvaluation

* Use case-insensitive comparison for CORS preflight responses (#11511)

* Remove usage of RestoreUseStaticGraphEvaluation

* Add test ValidatePreflightResponseHeadersCaseMismatchSucceeds

* Use case-insensitive comparer for AllowedHeaders

* Change files

* Revert "Remove usage of RestoreUseStaticGraphEvaluation"

This reverts commit 735b168.

* Rename ConstWcharComparer to CaseInsensitiveComparer

* Update vnext/Desktop.UnitTests/OriginPolicyHttpFilterTest.cpp

Co-authored-by: Danny van Velzen <dannyvv@microsoft.com>

* Remove unused code

* Make ExposedHeaders case-insensitive

---------

Co-authored-by: Danny van Velzen <dannyvv@microsoft.com>

* Change multi_threaded_map to single_threaded_map in WinRTHttpResource (#11604)

* Change multi_threaded_map to single_threaded_map in WinRTHttpResource

* Change files

* Fix fetch failing with certain custom user agents (#11775)

* Fix fetch failing with certain custom user agents

* Change files

* Bump C++ Windows Version macros to Windows 10 (#11516)

* Bump default _WIN32_WINNT_VERSION

* Change files

* Remove unused Beast-dependent code (#11517)

* Remove unused Beast production code

* Change files

* clang format

---------

Co-authored-by: Andrew Coates <30809111+acoates-ms@users.noreply.github.com>

* Define FileReader turbo module (#11789)

* Declare FileReaderTurboModule

* Declare m_blobPersistor

* Use msrn namespace alias in FileReader module

* json lock

* Update lock files

* config

* Implement ReadAsDataUrl

* Define ReadAsText

* Define FileReaderResource

* Move persistor from module into resource

* Rename module name name

* Add using ModuleSpec

* clang format

* Change files

* Define WebSocket TurboModule (#11802)

* Add WSTurboModule.h

* Implement CreateResource and MSRN SendEvent

* Define IWebSocketModuleContentHandler::ProcessMessage with JSValueObject

* Complete WebSocketTurboModule::CreateResource

* Complete WebSocketTurboModule::Connect

* Implement close, send, sendBinary and ping

* Include NativeWebSocketModuleSpec

* Make Close spec-compliant

* Add spec-compliant method stubs

* Make remaining existing methods spec-compliant

* Move NOOP Add/RemoveListeners implementation into source file

* clang format

* Use double as keys for m_resourceMap

* Change files

* Define HTTP TurboModule (#11825)

* Declare TurboModule

* Generate NativeNetworkingWindows spec

* Define HttpTurboModule

* Begin resource setup

* Initialize: Up to SetOnData

* Define wchar_t event names

* Migrate IRequestBodyHandler to JSValue

IMPORTANT: Migrate and fix RequestArgs::Data

* Migrate IResponseHandler to JSValue

* Rename m_onDataDynamic as m_onDataObject

* Implement Microsoft::React::Modules::ToJSValue

* Migrate IHttpResource to JSValue

* Fix Playground flavors ordering

* Finish implementing Initialize

* Define ToDynamic

* Change files

* Revert module.g.cpp

* Revert "Revert module.g.cpp"

This reverts commit 2f6c88a.

* Define target SetCppWinRTReferences

* clang format

* Revert temporary symbol exports

* Fix RedirectHttpFilterUnitTest import order

* Preserve include ordering in RedirectHttpFilterUnitTest.cpp

* Fix JSValueArray list constructor

* Drop RCTNetworkingNative in favor of NativeNetworkingWindows

* Add NativeNetworkingWindows to overrides

* Fix overrides.json newline

* Desktop int. tests: set RN_PLATFORM to win32

* Use iterator to lookup content types

* Revert module.g.cpp to main

* Use iterator for ToRequestBody content type

* Drop namespace from JSValueObject usage

* Finish HttpTurboModule

* clang format

* Use iOS HTTP spec

* Use DynamicReader and DynamicWriter for folly conversions

* Revert overrides.json

* Don't add newline to overrides.json

* Make RCTNetworking.windows.js a copy of RCTNetworking.ios.js

* Override upgrade

* Default IncludeFabricInterface to true (#11835)

* Default IncludeFabricInterface to true

* Change files

* Remove IncludeFabricInterface from ExperimentalFeatures

* Define Blob TurboModule (#11842)

* REVERT: remove CompositionView exports

* Declare BlobTurboModule

* Revert "REVERT: remove CompositionView exports"

This reverts commit 1ba874e.

* Define BlobTurboModule

* Declare IBlobResource

* Define DefaultBlobResource

* Define BlobCallbacks

* Migrate BlobWebSocketModuleContentHandler

* Pass needed args to DefaultBlobResource

* Define IBlobResource +/- network handlers

* Implement BlobModule using IBlobResource

* Fix GetConstants ownership

* Change files

* Set up error callback!

* clang format

* Remove BlobModule::SharedState

* Clean up includes and usings

* Remove ProcessMessage folly variant

* Remove folly:dynamic references

* Define IBlobResource::FieldNames

* Move IBlobPersistor out of Modules/

* Remove TODO comments

* clang format

* Add missing include to DefaultBlobResource

* Use TurboModules for networking in MSRN (#11867)

* Update packages.json

* Define GetHttpTurboModuleName

* Update packages.json

* Define GetHttpModuleProvider

* Define other netwk modules provider methods

* Register networking turbomodules

* Change files

* clang format

* Uncomment MSRN forward declarations

* Remove cntPtr.h include

* Remove CoreNativeModules

* Revert packages.lock.json

* Remove change files

* Change files

* Revert lock files

* Generalize FileReader promise type parameters

* Adjust Networking override to v0.71.x

* Use correct data types in FileReaderTurboModule::ReadAs* (#11902)

* Use ReadAs* data argument as JSValueObject

* Change files

---------

Co-authored-by: Danny van Velzen <dannyvv@microsoft.com>
Co-authored-by: Liron Yahdav <lyahdav@users.noreply.github.com>
Co-authored-by: Andrew Coates <30809111+acoates-ms@users.noreply.github.com>
JunielKatarn added a commit to jurocha-ms/react-native-windows that referenced this pull request Aug 29, 2023
* Declare TurboModule

* Generate NativeNetworkingWindows spec

* Define HttpTurboModule

* Begin resource setup

* Initialize: Up to SetOnData

* Define wchar_t event names

* Migrate IRequestBodyHandler to JSValue

IMPORTANT: Migrate and fix RequestArgs::Data

* Migrate IResponseHandler to JSValue

* Rename m_onDataDynamic as m_onDataObject

* Implement Microsoft::React::Modules::ToJSValue

* Migrate IHttpResource to JSValue

* Fix Playground flavors ordering

* Finish implementing Initialize

* Define ToDynamic

* Change files

* Revert module.g.cpp

* Revert "Revert module.g.cpp"

This reverts commit 2f6c88a.

* Define target SetCppWinRTReferences

* clang format

* Revert temporary symbol exports

* Fix RedirectHttpFilterUnitTest import order

* Preserve include ordering in RedirectHttpFilterUnitTest.cpp

* Fix JSValueArray list constructor

* Drop RCTNetworkingNative in favor of NativeNetworkingWindows

* Add NativeNetworkingWindows to overrides

* Fix overrides.json newline

* Desktop int. tests: set RN_PLATFORM to win32

* Use iterator to lookup content types

* Revert module.g.cpp to main

* Use iterator for ToRequestBody content type

* Drop namespace from JSValueObject usage

* Finish HttpTurboModule

* clang format

* Use iOS HTTP spec

* Use DynamicReader and DynamicWriter for folly conversions

* Revert overrides.json

* Don't add newline to overrides.json

* Make RCTNetworking.windows.js a copy of RCTNetworking.ios.js

* Override upgrade
JunielKatarn added a commit to jurocha-ms/react-native-windows that referenced this pull request Aug 29, 2023
* Declare TurboModule

* Generate NativeNetworkingWindows spec

* Define HttpTurboModule

* Begin resource setup

* Initialize: Up to SetOnData

* Define wchar_t event names

* Migrate IRequestBodyHandler to JSValue

IMPORTANT: Migrate and fix RequestArgs::Data

* Migrate IResponseHandler to JSValue

* Rename m_onDataDynamic as m_onDataObject

* Implement Microsoft::React::Modules::ToJSValue

* Migrate IHttpResource to JSValue

* Fix Playground flavors ordering

* Finish implementing Initialize

* Define ToDynamic

* Change files

* Revert module.g.cpp

* Revert "Revert module.g.cpp"

This reverts commit 2f6c88a.

* Define target SetCppWinRTReferences

* clang format

* Revert temporary symbol exports

* Fix RedirectHttpFilterUnitTest import order

* Preserve include ordering in RedirectHttpFilterUnitTest.cpp

* Fix JSValueArray list constructor

* Drop RCTNetworkingNative in favor of NativeNetworkingWindows

* Add NativeNetworkingWindows to overrides

* Fix overrides.json newline

* Desktop int. tests: set RN_PLATFORM to win32

* Use iterator to lookup content types

* Revert module.g.cpp to main

* Use iterator for ToRequestBody content type

* Drop namespace from JSValueObject usage

* Finish HttpTurboModule

* clang format

* Use iOS HTTP spec

* Use DynamicReader and DynamicWriter for folly conversions

* Revert overrides.json

* Don't add newline to overrides.json

* Make RCTNetworking.windows.js a copy of RCTNetworking.ios.js

* Override upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants