mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix nullability annotations in iOS networking headers (#59240)
Summary: Importing `RCTMultipartDataTask.h` and `RCTHTTPRequestHandler.h` produces nullability-completeness warnings because the headers mix annotated return values with unannotated pointers and blocks. Complete the annotations with `NS_ASSUME_NONNULL`, keeping optional configuration providers, interceptors, progress handlers and multipart callback payloads nullable. This matches the existing implementations, including clearing an interceptor with `nil` and reporting a failed multipart response without headers or content. ## Changelog: [IOS] [FIXED] - Fix missing nullability annotations in networking headers. Pull Request resolved: https://github.com/react/react-native/pull/59240 Test Plan: - Compiled a translation unit importing both headers with the Xcode 27.1 iOS Simulator SDK, ARC, blocks and `-Werror`. Passed in Objective-C and Objective-C++ modes. It also exercises clearing all three providers/interceptors with `nil`, returning `nil` from each interceptor, nullable multipart callback payloads and an absent progress callback. - The same header import on the original revision fails with nine `-Wnullability-completeness` errors. - Compiled `RCTMultipartDataTask.m` with `-fsyntax-only -Werror=nullability-completeness` against the same SDK. Passed. - Checked both changed headers with the repository's pinned clang-format 21.1.2 (`--dry-run --Werror`) and ran `git diff --check`. Passed. A full RNTester build was not run for this header-only change. Snapshot completion (local update): - Added the four generated ReactApple API snapshots from the CI artifact for PR head `151876277233befdbe7c0d9818039aa08ad15d1c`; verified the artifact SHA-256 against GitHub metadata. Imported headers and all prior snapshots match that revision. No header implementation or dependency changes. - The repository `validate_snapshots` comparison passes for all 12 generated views. `arc lint -a` reports no lint issues. - Full local `buck2 run fbsource//xplat/js/react-native-github/scripts/cxx-api:api-snapshot` could not regenerate: the existing codegen environment lacks `tinyglobby`. The updated files are exact generated CI output, not hand-edited snapshots. Reviewed By: christophpurrer Differential Revision: D126472293 Pulled By: javache fbshipit-source-id: 0c4f87e4d6f8c57f89f9e914d1c44a60802df1b6
This commit is contained in:
1 parent
7b6516eb11
commit
c7429b0e97
6 files changed
+20
-11
No files matched your search
@@ -8,12 +8,14 @@
|
||||
#import <React/RCTInvalidating.h>
|
||||
#import <React/RCTURLRequestHandler.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NSURLSessionConfiguration *_Nullable (^NSURLSessionConfigurationProvider)(void);
|
||||
/**
|
||||
* The block provided via this function will provide the NSURLSessionConfiguration for all HTTP requests made by the
|
||||
* app.
|
||||
*/
|
||||
RCT_EXTERN void RCTSetCustomNSURLSessionConfigurationProvider(NSURLSessionConfigurationProvider /*provider*/);
|
||||
RCT_EXTERN void RCTSetCustomNSURLSessionConfigurationProvider(NSURLSessionConfigurationProvider _Nullable /*provider*/);
|
||||
|
||||
typedef NSURLRequest *_Nullable (^RCTHTTPRequestInterceptor)(NSURLRequest *request);
|
||||
/**
|
||||
@@ -21,7 +23,7 @@ typedef NSURLRequest *_Nullable (^RCTHTTPRequestInterceptor)(NSURLRequest *reque
|
||||
* they are sent. Return a modified request to override, or nil to use the
|
||||
* original request unchanged.
|
||||
*/
|
||||
RCT_EXTERN void RCTSetCustomHTTPRequestInterceptor(RCTHTTPRequestInterceptor /*interceptor*/);
|
||||
RCT_EXTERN void RCTSetCustomHTTPRequestInterceptor(RCTHTTPRequestInterceptor _Nullable /*interceptor*/);
|
||||
|
||||
/**
|
||||
* This is the default RCTURLRequestHandler implementation for HTTP requests.
|
||||
@@ -29,3 +31,5 @@ RCT_EXTERN void RCTSetCustomHTTPRequestInterceptor(RCTHTTPRequestInterceptor /*i
|
||||
@interface RCTHTTPRequestHandler : NSObject <RCTURLRequestHandler, RCTInvalidating>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -10,11 +10,13 @@
|
||||
#import <React/RCTDefines.h>
|
||||
#import <React/RCTMultipartStreamReader.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void (^RCTMultipartDataTaskCallback)(
|
||||
NSInteger statusCode,
|
||||
NSDictionary *headers,
|
||||
NSData *content,
|
||||
NSError *error,
|
||||
NSDictionary *_Nullable headers,
|
||||
NSData *_Nullable content,
|
||||
NSError *_Nullable error,
|
||||
BOOL done);
|
||||
|
||||
typedef NSURLRequest *_Nullable (^RCTMultipartDataTaskRequestInterceptor)(NSURLRequest *request);
|
||||
@@ -23,14 +25,17 @@ typedef NSURLRequest *_Nullable (^RCTMultipartDataTaskRequestInterceptor)(NSURLR
|
||||
* requests before they are sent. Return a modified request to override, or nil
|
||||
* to use the original request unchanged.
|
||||
*/
|
||||
RCT_EXTERN void RCTSetCustomMultipartDataTaskRequestInterceptor(RCTMultipartDataTaskRequestInterceptor /*interceptor*/);
|
||||
RCT_EXTERN void RCTSetCustomMultipartDataTaskRequestInterceptor(
|
||||
RCTMultipartDataTaskRequestInterceptor _Nullable /*interceptor*/);
|
||||
|
||||
@interface RCTMultipartDataTask : NSObject
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)url
|
||||
partHandler:(RCTMultipartDataTaskCallback)partHandler
|
||||
progressHandler:(RCTMultipartProgressCallback)progressHandler;
|
||||
progressHandler:(nullable RCTMultipartProgressCallback)progressHandler;
|
||||
|
||||
- (void)startTask;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1410,7 +1410,7 @@ interface RCTMountingManager : public NSObject {
|
||||
}
|
||||
|
||||
interface RCTMultipartDataTask : public NSObject {
|
||||
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler);
|
||||
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
|
||||
public virtual void startTask();
|
||||
}
|
||||
|
||||
|
||||
@@ -1453,7 +1453,7 @@ interface RCTMountingManager : public NSObject {
|
||||
}
|
||||
|
||||
interface RCTMultipartDataTask : public NSObject {
|
||||
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler);
|
||||
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
|
||||
public virtual void startTask();
|
||||
}
|
||||
|
||||
|
||||
@@ -1410,7 +1410,7 @@ interface RCTMountingManager : public NSObject {
|
||||
}
|
||||
|
||||
interface RCTMultipartDataTask : public NSObject {
|
||||
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler);
|
||||
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
|
||||
public virtual void startTask();
|
||||
}
|
||||
|
||||
|
||||
@@ -1410,7 +1410,7 @@ interface RCTMountingManager : public NSObject {
|
||||
}
|
||||
|
||||
interface RCTMultipartDataTask : public NSObject {
|
||||
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, RCTMultipartProgressCallback progressHandler);
|
||||
public virtual instancetype initWithURL:partHandler:progressHandler:(NSURL* url, RCTMultipartDataTaskCallback partHandler, _Nullable RCTMultipartProgressCallback progressHandler);
|
||||
public virtual void startTask();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user