Skip to content

Commit 29c9626

Browse files
committed
chore: README update
1 parent ed0edbe commit 29c9626

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Easily integrate the most reliable native networking libraries with the latest a
2828
- Everything runs on a native background thread
2929
- Transparent GZIP
3030
- HTTP/2 support
31+
- Multiform part
32+
- Cache
33+
- Basic Cookie support
3134

3235
## FAQ
3336
> What the flip is SSL pinning and all this security mumbo jumbo?
@@ -98,6 +101,39 @@ Https.disableSSLPinning()
98101
```
99102
All requests after calling this method will no longer utilize SSL pinning until it is re-enabled once again.
100103

104+
105+
### Cookie
106+
107+
By default basic Cookie support is enabled to work like in {N} `http` module.
108+
In the future more options will be added
109+
110+
### Enabling Cache
111+
112+
```typescript
113+
import { knownFolders, path } from '@nativescript/core/file-system';
114+
import * as Https from 'nativescript-https'
115+
Https.setCache({
116+
diskLocation: path.join(knownFolders.documents().path, 'httpcache'),
117+
diskSize: 10 * 1024 * 1024 // 10 MiB
118+
});
119+
120+
/// later on when calling your request you can use the cachePolicy option
121+
```
122+
123+
### Multipart form data
124+
125+
If you set the `Content-Type` header to `"multipart/form-data"` the request body will be evaluated as a multipart form data. Each body parameter is expected to be in this format:
126+
```typescript
127+
{
128+
data: any
129+
parameterName: string,
130+
fileName?: string
131+
contentType?: string
132+
}
133+
134+
```
135+
if `fileName` and `contentType` are set then data is expected to be either a `NSData` on iOS or a `native.Array<number>` on Android.
136+
101137
### Options
102138
```typescript
103139
export interface HttpsSSLPinningOptions {
@@ -106,6 +142,9 @@ export interface HttpsSSLPinningOptions {
106142
allowInvalidCertificates?: boolean
107143
validatesDomainName?: boolean
108144
commonName?: string
145+
useLegacy?: boolean
146+
cachePolicy?: 'noCache' | 'onlyCache' | 'ignoreCache'
147+
onProgress?: (current: number, total: number) => void
109148
}
110149
```
111150
Option | Description
@@ -116,6 +155,8 @@ Option | Description
116155
`allowInvalidCertificates?: boolean` | Default: `false`. This should **always** be `false` if you are using SSL pinning. Set this to `true` if you're using a self-signed certificate.
117156
`validatesDomainName?: boolean` | Default: `true`. Determines if the domain name should be validated with your pinned certificate.
118157
`useLegacy?: boolean` | Default: `false`. [IOS only] set to true in order to get the response data (when status >= 300)in the `content` directly instead of `response.body.content`.
158+
`cachePolicy?: 'noCache' | 'onlyCache' | 'ignoreCache'` | Set the cache policy to use with that request. This only works with GET requests for now.
159+
`onProgress?: (current: number, total: number) => void` | [IOS only] Set the progress callback.
119160

120161
## Webpack / bundling
121162
Since you're probably shipping a certificate with your app (like [our demo does](https://github.com/EddyVerbruggen/nativescript-https/tree/master/demo/app/assets)),

0 commit comments

Comments
 (0)