http#OutgoingHttpHeaders TypeScript Examples

The following examples show how to use http#OutgoingHttpHeaders. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: sessionTokenManager.ts    From cloudant-node-sdk with Apache License 2.0 6 votes vote down vote up
/**
   * Only base service specific headers are in use.
   *
   * @param {OutgoingHttpHeaders} headers - the new set of headers as an object
   * @returns {Error}
   */
  // eslint-disable-next-line class-methods-use-this
  public setHeaders(headers: OutgoingHttpHeaders): void {
    const errMsg =
      'During CouchDB Session Authentication only `request` service headers are in use';
    throw new Error(errMsg);
  }
Example #2
Source File: ntrip-push-pull.ts    From caster with GNU General Public License v3.0 6 votes vote down vote up
// noinspection JSUnusedGlobalSymbols
    /**
     * Internal method that stores the request header.
     * Override to include RTSP in status line.
     *
     * @param firstLine HTTP request status line
     * @param headers HTTP headers
     * @private
     */
    _storeHeader(firstLine: string, headers: OutgoingHttpHeaders) {
        if (this.statusVersion !== undefined)
            firstLine = firstLine.slice(0, firstLine.lastIndexOf(' ') + 1) + this.statusVersion + '\r\n';

        if (this.sourceSecret !== undefined)
            firstLine = firstLine.slice(0, firstLine.indexOf(' ') + 1) +
                    this.sourceSecret + firstLine.slice(firstLine.indexOf(' '));

        // @ts-ignore Call private _storeHeader
        super._storeHeader(firstLine, headers);
    }
Example #3
Source File: ntrip.ts    From caster with GNU General Public License v3.0 6 votes vote down vote up
// noinspection JSUnusedGlobalSymbols
    /**
     * Internal method that stores the response header.
     * Override to include NTRIP V1 responses such as ICY 200 OK and SOURCETABLE 200 OK.
     *
     * @param firstLine HTTP response status line
     * @param headers HTTP headers
     * @private
     */
    _storeHeader(firstLine: string, headers: OutgoingHttpHeaders) {
        firstLine = this.statusVersion + firstLine.slice(firstLine.indexOf(' '));
        // @ts-ignore Call private _storeHeader
        super._storeHeader(firstLine, headers);

        //console.log(chalk.green(firstLine));
        for (let header in headers) {
            // @ts-ignore
            //console.log(chalk.green(headers[header][0] + ": " + headers[header][1]));
        }
    }
Example #4
Source File: AppUpdater.ts    From electron-differential-updater with MIT License 6 votes vote down vote up
private computeRequestHeaders(provider: Provider<any>): OutgoingHttpHeaders {
    const fileExtraDownloadHeaders = provider.fileExtraDownloadHeaders;
    if (fileExtraDownloadHeaders != null) {
      const requestHeaders = this.requestHeaders;
      return requestHeaders == null
        ? fileExtraDownloadHeaders
        : {
            ...fileExtraDownloadHeaders,
            ...requestHeaders
          };
    }
    return this.computeFinalHeaders({ accept: "*/*" });
  }
Example #5
Source File: Provider.ts    From electron-differential-updater with MIT License 6 votes vote down vote up
protected createRequestOptions(url: URL, headers?: OutgoingHttpHeaders | null): RequestOptions {
    const result: RequestOptions = {}
    if (this.requestHeaders == null) {
      if (headers != null) {
        result.headers = headers
      }
    }
    else {
      result.headers = headers == null ? this.requestHeaders : {...this.requestHeaders, ...headers}
    }

    configureRequestUrl(url, result)
    return result
  }
Example #6
Source File: AppUpdater.ts    From electron-differential-updater with MIT License 5 votes vote down vote up
private computeFinalHeaders(headers: OutgoingHttpHeaders) {
    if (this.requestHeaders != null) {
      Object.assign(headers, this.requestHeaders);
    }
    return headers;
  }
Example #7
Source File: AppUpdater.ts    From electron-differential-updater with MIT License 5 votes vote down vote up
/**
   *  The request headers.
   */
  requestHeaders: OutgoingHttpHeaders | null = null;
Example #8
Source File: PrivateGitHubProvider.ts    From electron-differential-updater with MIT License 5 votes vote down vote up
protected createRequestOptions(url: URL, headers?: OutgoingHttpHeaders | null): RequestOptions {
    const result = super.createRequestOptions(url, headers);
    (result as any).redirect = "manual"
    return result
  }
Example #9
Source File: Provider.ts    From electron-differential-updater with MIT License 5 votes vote down vote up
setRequestHeaders(value: OutgoingHttpHeaders | null): void {
    this.requestHeaders = value
  }
Example #10
Source File: Provider.ts    From electron-differential-updater with MIT License 5 votes vote down vote up
/**
   * Method to perform API request only to resolve update info, but not to download update.
   */
  protected httpRequest(url: URL, headers?: OutgoingHttpHeaders | null, cancellationToken?: CancellationToken): Promise<string | null> {
    return this.executor.request(this.createRequestOptions(url, headers), cancellationToken)
  }
Example #11
Source File: Provider.ts    From electron-differential-updater with MIT License 5 votes vote down vote up
private requestHeaders: OutgoingHttpHeaders | null = null
Example #12
Source File: HTTPResponse.ts    From dis.ts with MIT License 5 votes vote down vote up
headersOut: OutgoingHttpHeaders;
Example #13
Source File: express.ts    From api-example with MIT License 5 votes vote down vote up
export function writeJsonResponse(res: express.Response, code: any, payload: any, headers?: OutgoingHttpHeaders | undefined): void {
  const data = typeof payload === 'object' ? JSON.stringify(payload, null, 2) : payload
  res.writeHead(code, {...headers, 'Content-Type': 'application/json'})
  res.end(data)
}
Example #14
Source File: ResponseHeader.ts    From ZenTS with MIT License 5 votes vote down vote up
public all(): OutgoingHttpHeaders {
    return this.res.getHeaders()
  }