Граф коммитов

15 Коммитов

Автор SHA1 Сообщение Дата
Julio César Rocha b412977a80
Implement Blob module (#9352)
* 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)
2022-05-20 19:48:48 -07:00
Julio César Rocha 25d76fc058
Implement Origin Policy filter (#9771)
* Move all awaitable code into PerformSendRequest

* Await coroutine methods

* Remove blank lines

* Simplify co_return UntrackResponse

* Use dynamic body for server internal request

* Defne SetOnOptions

* Move url before headers in Response type

* Add dummy preflight filter

* Update x64 exports

* Use strand for server IO context

* Use HTTP message aliases

* Use HTTP message aliases

* Do not keep session references

Allows dropping server scope in tests.

* Comment out server scopes

* Use DynamicRequest|Response alias

* Format

* Use thread vector

* Drop outdated boost package validation in ReactCommon

* Define experimental write strand

* Drop server scope in default test

* Also pass server context to sessions

* Disable resource in default test

* Use Beast example

* Remove unused sample code

* Create HttpServer as listener wrapper

* Pass callbacks down to session

* Strong-name response as DynamicResponse

* Use DynamicRequest in handle_request

* Define HandleRequest as member function

* Lambda-based Respond()

* #if-out original sample code

* Keep count on get: ReaGetSucceeds

* Implement lambda_ using std::function

* Run context in io thread

* Join threads in Stop method

* Port send lambda to MS::R::T::HttpServer

* Update other basic tests

* Ensure Get+Options sequencing

* Clean up comments

* Use Callbacks() method

* Add concurrency argument

* Reduce macro usage

* Fix default OPTIONS handler

* Ensure number of headers

* Define ResponseType

* Use ResponseWrapper for polymorphism

* Define remaining wrapped types (File, String)

* Clean up server code

* (WIP) add test PreflightSucceeds

* catch hresult_error

* Use ProcessRequest result in PreformSendReq

* Rename test header value to Requested

* Propagate orror in ProcessRequest

* Rename OPReqFilter to PrototypeReqFilter

* Port request filter to WinRT IHttpFilter subtype

* Define allowed/forbidden methods and headers

* Define MSRN::Networking::OriginPolicyHttpFilter

* Move networking types into Shared\Networking folder

* Refactor: Move network types to Microsoft::React::Networking

* Clean up commented inline

* Make OPFilter::SendAsync non const

* Remove PrototypeHttpFilter

* Temporarily have desk.ITs depend on CppWinRT

* Define test OriginPolicyHttpFilterTest::UrlsHaveSameOrigin

* Add more same origin tests

* Start implementing ValidateRequest

* Finish ValidateRequest()

* Rename SingleOrigin to SameOrigin

* Implement SendPreflightAsync

* Fix OP assignment and GetOrigin rendering

* Parse Access-Control-Allow-Headers

* Done extracting access control values

* Use request as argument of ValidatePreflightResponse

* clang format

* Pass RequestArgs to request properties

* Pass RequestArgs to ValidateAllowOrigin

* Remove prototype non-WinRT filter

* Implement CorsUnsafeNotForbiddenRequestHeaderNames

* Test WinRT RequestHeader case sensitivity

* Fix ValidateAllowOrigin 4.10.5

* Add HttpOriginPolicyIntegrationTest

* Use boost:iequals to compare method names

* Add server support for CONNECT and TRACE methods

* Make HttpServer port uint16_t

* Prelfight only when OP is CORS.

- Add test SimpleCorsSameOriginSucceededs
- Add test NoCorsCrossOriginPatchSucceededs
- Add test NoCorsCrossOriginFetchRequestSucceeds
- Add test HTTP Server support for PATCH

* Use runtime option Http.StrictScheme

* Drop namespace from OriginPolicy

* Remove Origin from request heders

* Clean includes and usings in WinRTHttpResource.cpp

* Update preflight cache issue references (#9770)

* Pass origin in IHttpResource constructor

* clang format

* Prevent nullptr access when iterating preflight request headers

* Include request content headers in preflight headers list

* Send preflight to original request URL.

- Change test origin URL to non-existing http://example.rnw
- Have OriginPolicyHttpFilter::SendRequestAsync catch hresult_error to
  avoid losing info in (...) clause.

* Export APIs Set/GetRuntimeOptionString

- Switch to class-level static origin Uri.
- Define static (global) origin Uri via runtime option
  "Http.GlobalOrigin".

* clang format

* Implement TestOriginPolicy to parameterize OP tests

* Clean up non-parameterized tests

* Use constant for dummy cross origin

* Simplify test param constructors

* Start implementing ValidateResponse

* Add more tests

- FullCorsCrossOriginMissingCorsHeadersFails
- FullCorsCrossOriginMismatchedCorsHeaderFails

* clang format

* Change files

* Update namespaces in MSRN solution

* Move RequestArgs and ResponseType into new header

* Implement ExtractAccessControlValues

- Validate test result against ServerParams::Response::result

* Report specific origin mismatch errors in ValidatePreflightResponse

* Declare FullCorsCrossOriginCheckFailsOnPreflightRedirectFails

* Add ABI-safe runtime options free functions.

- Microsoft_React_SetRuntimeOptionBool
- Microsoft_React_SetRuntimeOptionInt
- Microsoft_React_SetRuntimeOptionString
- Microsoft_React_GetRuntimeOptionBool
- Microsoft_React_GetRuntimeOptionInt
- Microsoft_React_GetRuntimeOptionString

* Drop namespaced GetRuntimeOptionString

* Use case-insensitive comparison

* Drop newline from error message

* Return unmanaged copy in GetRuntimeOptionString

* Update FullCorsCrossOriginCheckFailsOnPreflightRedirectFails args

* Disallow preflight redirect.

See https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSExternalRedirectNotAllowed

* Replace winrt::get_self<D,I> with .as<D>

* Drop LF from error messages

* Use self-managed variable port in tests

* Start writing FullCorsCorsCheckFailsOnResponseRedirectFails

* Scope disabling autoredirect to preflight request only

* Update TODOs with open issues

* Compute originAllowed

* Add test FullCorsSameOriginToSameOriginRedirectSucceeds

* Test FullCorsSameOriginToCrossOriginRedirectSucceeds

* Test FullCorsCrossOriginToOriginalOriginRedirectFails

* Declare FullCorsCrossOriginToAnotherCrossOriginRedirectSucceeds

* Implement OriginPolicyHttpFilter::ConstWcharComparer

* Use _wcsicmp instead of boost::iequals in ConstWcharComparer

* Correct SimpleCORS value search

* Disable FullCorsCrossOriginWithCredentialsSucceeds for now

* Rename type alias ResponseType to ResponseOperation

* clang format

* Handle originPolicy a request property instead of a member variable

* Avoid iterating response headers while removing items

* Gracefully fail when adding bad request headers

- Write remaining integration tests

* Use boost::iequals in PerformSendRequest

* clang format

* Use s_port for redirServer args

* Rename TestOriginPolicy to TestOriginPolicyWithRedirect

* Temporarily disabled tests

- FullCorsCrossOriginToAnotherCrossOriginRedirectWithPreflightSucceeds -
  pending redirect
- FullCorsRequestWithHostHeaderFails - Host request header is probematic

* Use std::queue for nonSimpleNames

* Finish ValidateResponse

* Clean up comments

* Add Test ExcludeHttpOnlyCookies

* Add tests KeepNonHttpOnlyCookies, RemoveAllCookies

* Address TODO comments

* Always allow simple-CORS methods in preflight

* Avoid auto for loop indexe sused against container .size()

* Update Desktop.Test.DLL exports for ARM64

* Skip test FullCorsCrossOriginToAnotherCrossOriginRedirectSucceeds

* Disable FullCorsCrossOriginToAnotherCrossOriginRedirectWithPreflightFails

* Ignore SimpleCorsForbiddenMethodFails

* Ignore SimpleCorsCrossOriginFetchFails

* RequestWithProxyAuthorizationHeaderFails

* Ignore SimpleCorsSameOriginSucceededs

* Ignore NoCorsCrossOriginFetchRequestSucceeds

* Revert "Ignore NoCorsCrossOriginFetchRequestSucceeds"

This reverts commit b5445fb5af.

* Revert "Ignore SimpleCorsSameOriginSucceededs"

This reverts commit ab75c37373.

* Revert "RequestWithProxyAuthorizationHeaderFails"

This reverts commit 70148b17de.

* Revert "Ignore SimpleCorsCrossOriginFetchFails"

This reverts commit 982e4508b9.

* Revert "Ignore SimpleCorsForbiddenMethodFails"

This reverts commit 869bda9782.

* Revert "Disable FullCorsCrossOriginToAnotherCrossOriginRedirectWithPreflightFails"

This reverts commit e9e178a07a.

* Revert "Skip test FullCorsCrossOriginToAnotherCrossOriginRedirectSucceeds"

This reverts commit 6688e7dce5.

* Skip OP integration tests

* Empty commit

* Use scoped_lock for runtime options

* Testing signature

* Have C++ Rt Option functions call ABI-safe ones

* Ensure different ports for each netwk test class

* Remove remaining hard-coded ports from WS tests

* Use ABI-safe callback for GetRtOptString

* Only insert boolean rt options when true

* Use static variable for port in HttpResourceIntegrationTest

* Add HttpResourceIntegrationTest::SimpleRedirectSucceeds

* Move C++ Rt Optio APIs to new header CppRuntimeOptions.h

* Implement internal Set/GetRuntimeOptionString

* clang format

* Rename Microsoft_React_* functions to MicrosoftReact*

* Update nuspec
2022-04-20 23:49:37 +00:00
Julio César Rocha 02f8b9f177
Avoid capturing raw `this` pointer in WebSocket module (#9247)
* Use implicit (brace) constructor for getMethods()

* Define CxxModuleHolder

* Make m_asyncStorageManager shared_ptr

* Change files

* Initialize m_holder

* Implement WebSocketModule::SharedState

* Move ResourceFactory into shared state

* Revert AsyncStorage changes

* Add URL argument to IWebSocketResource::Connect

* Drop URL from factory method

* Update BeastWebSocketResource

* Handle malformed Uris within ::Connect()

* Remove urlString argument from IWebSocketResource::Make

* Use constexpr for commont test URLs

* Remove redundant move in to_hstring

* Add/remove std::move where applicable

Co-authored-by: Nick Gerleman <ngerlem@microsoft.com>
2021-12-10 01:21:43 +00:00
Julio César Rocha 89535226a5
Allow propagating WinRTWebSocketResource constructor exceptions (#7892)
* Correctly format message on hresult_error

* Remove noexcept from public constructors
2021-05-29 17:31:34 -07:00
Julio César Rocha 3892ec0503
Handle MessageWebSocket constructor exceptions (#5629)
* Remove unused WebSocket factory arguments

* Add test InternalSocketThrowsHResult

* Change files

* Relocate InternalSocketThrowsHResult

* Make url argument r-value reference

* Catch generic error
2020-08-05 00:45:11 +00:00
Andrew Coates 3f17d742ee
CELA open source policy no longer recommends all right reserved in license header (#5083)
* Latest CELA open source policy is to not include All right reserved

* Change files
2020-06-01 15:17:26 -07:00
Julio César Rocha a6d5ff4342
Implement WinRTWebSocket unit tests (#4767)
* Allow constructing resource with generalized types

* Use IMessageWebSocketMessageReceivedEventArgs

* Implement MockMessageWebSocket

* Implement MockMessageWebSocket

* Declare MockMessageWebSocket mocks

* clang format

* Implement mocked methods

* Define MockDataWriter

* Complete MockWebSocketResource.
TODO: Fix handler memory access when invoked explicitly.

* Implement ConnectSucceeds

* Upgrade to Microsoft.Windows.CppWinRT.2.0.200316.3

* Comment-out connect test.

* Move mocks into struct.

* Make MockMessageWebSocket extend implements<IWebSocket>

* Uncommented test partially

* Uncommented test partially

* Temporarily comment IMessageWebSocket mock usage

* Temporarily comment IMessageWebSocket mock usage

* Make MockMessageWebSocket extends implements<IMessageWebSocket>

* Implement Mocks.Control

* MockMessageWS implement same types as MessageWS.

* Also implement winrt::...IWebSocket

* Drop impls of IMessageWebSocket2,3

* Add /await compiler switch

* Implement no-op IAsyncAction

* Implement ThrowAsync

* Updated MockWebSocketResource Mocks

* Change files

* Make MockMessageWebSocket primarily IMessageWebSocket

* clang format
2020-05-02 09:24:58 +00:00
Julio César Rocha c8085b5bb8
Enable WebSocketModule unit tests (#4538)
* Prototype mockable MessageQueueThread and JSExecutor

* Declare MockJSExecutor::CallFunctionFunctor

* Add missing using std::unique_ptr

* Use WebSocketModule::MethodId

* clang format

* Make WebSocketModule methods override instead of virtual.

* Allow WebSocketModule to use custom resource factory

* Rename *Impl to *Mock

* Move Instance mocks into separate source files

* Move Instance mocks into separate source files

* Change files

* clang format

* Define WebSocketModule::SetResourceFactory
2020-04-10 01:12:31 +00:00
Nick Gerleman 6162b1f97f
Provide a Minimal PlatformConstants Implementation (#4075)
* Provide a Minimal PlatformConstants Implementation

Partially addresses #2077

During the upgrade to 0.61, we needed to patch out checks for React Native version since we did not have an implementation of PlatformConstants. This change adds a very minimal implementation of one. The provided constants already vary between platforms, so we have a bit of leeway here in what we decide to provide. The only currently shared API we don't provide is for checking OS version.

Update Platform JS with caching, tpying, and turbomodule changes made upstream. Move modules to a consitent folder. Fix a potential async memory safety issue adjacent to the change,

Tested using ReactUWP Playground RNTester.

* Change files

* Fix Format

* Update Header Paths

* Update a comment

* Fixup vcxproj files

* Add Missing Override

* Change Name to uppercase
2020-02-12 11:11:37 +00:00
Vladimir Morozov 7116fc2f4c
Replaced Catch2 unit tests with GTest based Motif tests (#4030)
* Replaced Catch2 unit tests with Motif GTest tests

* Change files

* Code formatting

* Added gtest to Microsoft.ReactNative.Cxx.UnitTests packages

* Removed gtest based unit test projects from x86 configurations because of stdcall vs cdecl issues
2020-02-05 22:22:43 +00:00
Alexander Sklar ce0f4a3a91
Change vNext format for max columns to 120 (#3497)
* change clang format column count to 120

* Change files

* add clang format
2019-10-23 14:48:09 -07:00
Yichen Yao 6b6d0bbbc0 Put desktop unit tests into namespaces. (#3098)
* Put desktop unit tests into namespaces.

* Change files

* Small fix for position of "clang-format on"
2019-09-09 21:18:20 +02:00
Andrew Coates b7b40b934e
Run clang-format on cpp/h files (#2716)
* Run clang-format on cpp/h files

* Rework includes so deviation from facebooks clang-format is not needed

* Move pch to own header include group to prevent pch from being sorted below other headers

* Fix up some bad merges
2019-07-02 11:26:21 -07:00
Andy Himberger f506430087
Enabling further C++ strict conformance (/permissive-) (#2429)
* add permissive- switch by default, except for desktop dir
2019-05-09 10:53:19 -07:00
Harini Kannan 48a23b5181 Renamed RNWCPP to vnext and RNWCS to current (#2405)
* Refactored root folders
* Updated path references
* Fixed appveyor.yml
2019-05-03 15:27:07 -07:00