Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return headers on successful response #265

Merged
merged 2 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ Event Data
|`id`|string|Required|The ID of the upload.|
|`responseCode`|string|Required|HTTP status code received|
|`responseBody`|string|Required|HTTP response body|
|`responseHeaders`|string|Required|HTTP response headers (Android)|

### cancelled

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class GlobalRequestObserverDelegate(reactContext: ReactApplicationContext) : Req
}

override fun onError(context: Context, uploadInfo: UploadInfo, exception: Throwable) {

val params = Arguments.createMap()
params.putString("id", uploadInfo.uploadId)

Expand All @@ -45,10 +44,15 @@ class GlobalRequestObserverDelegate(reactContext: ReactApplicationContext) : Req
}

override fun onSuccess(context: Context, uploadInfo: UploadInfo, serverResponse: ServerResponse) {
val headers = Arguments.createMap()
for ((key, value) in serverResponse.headers) {
headers.putString(key, value)
}
val params = Arguments.createMap()
params.putString("id", uploadInfo.uploadId)
params.putInt("responseCode", serverResponse.code)
params.putString("responseBody", serverResponse.bodyString)
params.putMap("responseHeaders", headers)
sendEvent("completed", params, context)
}

Expand Down