Socket
Socket
Sign inDemoInstall

xmlhttprequest-ssl

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    xmlhttprequest-ssl

XMLHttpRequest for Node


Version published
Weekly downloads
4M
increased by1.37%
Maintainers
1
Install size
46.6 kB
Created
Weekly downloads
 

Package description

What is xmlhttprequest-ssl?

The xmlhttprequest-ssl package is a Node.js module that provides an implementation of the XMLHttpRequest object, which is primarily used in web browsers for making HTTP requests. This package is designed to work with SSL (Secure Sockets Layer) for secure data transmission and is particularly useful for server-side applications that need to make HTTP requests in a way that's similar to client-side JavaScript code.

What are xmlhttprequest-ssl's main functionalities?

Making GET Requests

This feature allows you to make GET requests to retrieve data from a specified URL. The code sample demonstrates how to initiate a GET request, handle the response, and print the result or error.

const XMLHttpRequest = require('xmlhttprequest-ssl').XMLHttpRequest;
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://api.example.com/data', true);
xhr.onload = function () {
  if (xhr.status >= 200 && xhr.status < 300) {
    console.log('Response:', xhr.responseText);
  } else {
    console.error('Request failed');
  }
};
xhr.send();

Sending POST Requests

This feature enables sending POST requests to submit data to a server. The code sample shows how to set up a POST request, including setting the request header and sending data in JSON format.

const XMLHttpRequest = require('xmlhttprequest-ssl').XMLHttpRequest;
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://api.example.com/submit', true);
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhr.onload = function () {
  if (xhr.status >= 200 && xhr.status < 300) {
    console.log('Success:', xhr.responseText);
  } else {
    console.error('Request failed');
  }
};
xhr.send(JSON.stringify({ key: 'value' }));

Other packages similar to xmlhttprequest-ssl

Readme

Source

node-XMLHttpRequest

Fork of node-XMLHttpRequest by driverdan. Forked and published to npm because a pull request is not being created and merged. Changes made by rase- are needed for engine.io-client.

Usage

Here's how to include the module in your project and use as the browser-based XHR object.

var XMLHttpRequest = require("xmlhttprequest-ssl").XMLHttpRequest;
var xhr = new XMLHttpRequest();

Note: use the lowercase string "xmlhttprequest-ssl" in your require(). On case-sensitive systems (eg Linux) using uppercase letters won't work.

Original README

Usage

Here's how to include the module in your project and use as the browser-based XHR object.

var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();

Note: use the lowercase string "xmlhttprequest" in your require(). On case-sensitive systems (eg Linux) using uppercase letters won't work.

Versions

Version 2.0.0 introduces a potentially breaking change concerning local file system requests. If these requests fail this library now returns the errno (or -1) as the response status code instead of returning status code 0.

Prior to 1.4.0 version numbers were arbitrary. From 1.4.0 on they conform to the standard major.minor.bugfix. 1.x shouldn't necessarily be considered stable just because it's above 0.x.

Since the XMLHttpRequest API is stable this library's API is stable as well. Major version numbers indicate significant core code changes. Minor versions indicate minor core code changes or better conformity to the W3C spec.

License

MIT license. See LICENSE for full details.

Supports

  • Async and synchronous requests
  • GET, POST, PUT, and DELETE requests
  • All spec methods (open, send, abort, getRequestHeader, getAllRequestHeaders, event methods)
  • Requests to all domains

Known Issues / Missing Features

For a list of open issues or to report your own visit the github issues page.

  • Local file access may have unexpected results for non-UTF8 files
  • Synchronous requests don't set headers properly
  • Synchronous requests freeze node while waiting for response (But that's what you want, right? Stick with async!).
  • Some events are missing, such as abort
  • getRequestHeader is case-sensitive
  • Cookies aren't persisted between requests
  • Missing XML support
  • Missing basic auth

Keywords

FAQs

Last updated on 16 Jul 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc