diff --git a/CHANGELOG.md b/CHANGELOG.md index a354809..2872451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.0.2](https://github.com/nativescript-community/https/compare/v4.0.1...v4.0.2) (2022-04-26) + +### Bug Fixes + +* **android:** broken headers in response ([81d8479](https://github.com/nativescript-community/https/commit/81d8479a5dd44fb1e51212b8842c3409b7c23ed3)) + ## [4.0.1](https://github.com/nativescript-community/https/compare/v4.0.0...v4.0.1) (2022-04-25) ### Bug Fixes diff --git a/demo/app/main-page.ts b/demo/app/main-page.ts index b392e79..d172ba4 100644 --- a/demo/app/main-page.ts +++ b/demo/app/main-page.ts @@ -4,6 +4,16 @@ import * as fs from '@nativescript/core/file-system'; import * as dialogs from '@nativescript/core/ui/dialogs'; import * as Page from '@nativescript/core/ui/page'; +const folder = fs.knownFolders.temp().getFolder('cache'); +const diskLocation = folder.path; +const cacheSize = 10 * 1024 * 1024; +Https.setCache({ + // forceCache: true, + diskLocation, + diskSize: cacheSize, + memorySize: cacheSize +}); + let page; let viewModel; export function pageLoaded(args: Page.NavigatedData) { @@ -42,7 +52,7 @@ function getRequest(url: string, options?: Partial) { .then((response) => { page.bindingContext.currentRequest = null; page.bindingContext.progress = 0; - console.log('Https.request response', response.statusCode, response.content.contentLength, response.content.toString()); + console.log('Https.request response', response, response.content.toString()); return response; }) .catch(onError); diff --git a/lerna.json b/lerna.json index 1d61bc8..70ff3b1 100644 --- a/lerna.json +++ b/lerna.json @@ -2,7 +2,7 @@ "packages": [ "plugin" ], - "version": "4.0.1", + "version": "4.0.2", "command": { "publish": { "conventionalCommits": true diff --git a/plugin/CHANGELOG.md b/plugin/CHANGELOG.md index 853c1e6..6ebedf6 100644 --- a/plugin/CHANGELOG.md +++ b/plugin/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [4.0.2](https://github.com/nativescript-community/https/compare/v4.0.1...v4.0.2) (2022-04-26) + +### Bug Fixes + +* **android:** broken headers in response ([81d8479](https://github.com/nativescript-community/https/commit/81d8479a5dd44fb1e51212b8842c3409b7c23ed3)) + ## [4.0.1](https://github.com/nativescript-community/https/compare/v4.0.0...v4.0.1) (2022-04-25) **Note:** Version bump only for package @nativescript-community/https diff --git a/plugin/package.json b/plugin/package.json index 5e25406..14da722 100644 --- a/plugin/package.json +++ b/plugin/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript-community/https", - "version": "4.0.1", + "version": "4.0.2", "description": "Nativescript plugin for gestures", "main": "index", "sideEffects": false, diff --git a/plugin/platforms/android/java/com/nativescript/https/OkHttpResponse.java b/plugin/platforms/android/java/com/nativescript/https/OkHttpResponse.java index 4fe69be..aa746c0 100644 --- a/plugin/platforms/android/java/com/nativescript/https/OkHttpResponse.java +++ b/plugin/platforms/android/java/com/nativescript/https/OkHttpResponse.java @@ -457,7 +457,18 @@ public void run() { public static int getStatusCode(Response response) { return response.code(); } + public static String getMessage(Response response) { return response.message(); } + + public static String getHeaders(Response response) throws Exception { + JSONObject obj = new JSONObject(); + Headers headers = response.headers(); + for (int i = 0; i < headers.size(); i++) + { + obj.put(headers.name(i), headers.value(i)); + } + return obj.toString(); + } } \ No newline at end of file