feat(http): add support for new methods (#2249)

This commit is contained in:
Sefa Ilkimen 2018-03-12 00:22:05 +01:00
parent 0e68bd91f2
commit 4497e00670

View File

@ -33,7 +33,7 @@ export interface HTTPResponse {
* ```typescript * ```typescript
* import { HTTP } from '@ionic-native/http'; * import { HTTP } from '@ionic-native/http';
* *
* constructor(private http: HTTP) { } * constructor(private http: HTTP) {}
* *
* ... * ...
* *
@ -89,28 +89,56 @@ export class HTTP extends IonicNativePlugin {
useBasicAuth(username: string, password: string): void {} useBasicAuth(username: string, password: string): void {}
/** /**
* Set a header for all future requests. Takes a header and a value. * Get all headers defined for a given hostname.
* @param host {string} The hostname
* @returns {string} return all headers defined for the hostname
*/
@Cordova({ sync: true })
getHeaders(host: string): string {
return;
}
/**
* Set a header for all future requests. Takes a hostname, a header and a value.
* @param host {string} The hostname to be used for scoping this header
* @param header {string} The name of the header * @param header {string} The name of the header
* @param value {string} The value of the header * @param value {string} The value of the header
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
setHeader(header: string, value: string): void {} setHeader(host: string, header: string, value: string): void {}
/**
* Get the name of the data serializer which will be used for all future POST and PUT requests.
* @returns {string} returns the name of the configured data serializer
*/
@Cordova({ sync: true })
getDataSerializer(): string {
return;
}
/** /**
* Set the data serializer which will be used for all future POST and PUT requests. Takes a string representing the name of the serializer. * Set the data serializer which will be used for all future POST and PUT requests. Takes a string representing the name of the serializer.
* @param serializer {string} The name of the serializer. Can be urlencoded or json * @param serializer {string} The name of the serializer. Can be urlencoded, utf8 or json
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
setDataSerializer(serializer: string): void {} setDataSerializer(serializer: string): void {}
/** /**
* Clear all cookies * Add a custom cookie.
* @param url {string} Scope of the cookie
* @param cookie {string} RFC compliant cookie string
*/
@Cordova({ sync: true })
setCookie(url: string, cookie: string): void {}
/**
* Clear all cookies.
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
clearCookies(): void {} clearCookies(): void {}
/** /**
* Remove cookies * Remove cookies for given URL.
* @param url {string} * @param url {string}
* @param cb * @param cb
*/ */
@ -118,14 +146,23 @@ export class HTTP extends IonicNativePlugin {
removeCookies(url: string, cb: () => void): void {} removeCookies(url: string, cb: () => void): void {}
/** /**
* Disable following redirects automatically * Resolve cookie string for given URL.
* @param disable {boolean} Set to true to disable following redirects automatically * @param url {string}
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
disableRedirect(disable: boolean): void {} getCookieString(url: string): string { return; }
/** /**
* Set request timeout * Get global request timeout value in seconds.
* @returns {number} returns the global request timeout value
*/
@Cordova({ sync: true })
getRequestTimeout(): number {
return;
}
/**
* Set global request timeout value in seconds.
* @param timeout {number} The timeout in seconds. Default 60 * @param timeout {number} The timeout in seconds. Default 60
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
@ -155,6 +192,14 @@ export class HTTP extends IonicNativePlugin {
return; return;
} }
/**
* Disable following redirects automatically.
* @param disable {boolean} Set to true to disable following redirects automatically
* @returns {Promise<void>} returns a promise that will resolve on success, and reject on failure
*/
@Cordova()
disableRedirect(disable: boolean): Promise<void> { return; }
/** /**
* Make a POST request * Make a POST request
* @param url {string} The url to send the request to * @param url {string} The url to send the request to