Coder Social home page Coder Social logo

brq's Introduction

brq

A minimal request module.

Usage

import request from 'brq';
const response = await request('https://icanhazip.com');
console.log(response.text());

Contribution and License Agreement

If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work. </legalese>

License

  • Copyright (c) 2017, Christopher Jeffrey (MIT License).

See LICENSE for more info.

brq's People

Contributors

blusyn avatar bucko13 avatar chjj avatar nodech avatar pinheadmz avatar streetycat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brq's Issues

Add option to adjust timeout

If I try to access really large blocks I get a timeout.

Example:
bcoin-cli --network=testnet tx e191168694de35887e12f6e8ef32b3e4b6212b37bcad0e17a2fe3f8fa11a9f43

Error: Request timed out.
at Timeout.timeout.setTimeout (/home/bcoin/bcoin/node_modules/brq/lib/request.js:369:19)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)`

support content-type `text/json`

Using this library to fetch the cex.io API
Check it out:
https://cex.io/api/last_price/BTC/USD ➡️ content-type: text/json

and so I'm getting content-type errors from bcurl because this type does not === json Any reason not to include?

No tests

Tracking down an issue at bcoin-org/bcoin#549 and have ended up isolating the issue to be when brq is called from bcurl from bclient when calling createWallet.

Wanted to verify that tests are passing here correctly to help narrow it down, however found that are no tests.

Normalize paths.

brq does not normalize paths when parsing nor when constructing from object.

Example 1. brq('http://example.com/path/to/rss1/../rss2').

This will result requesting GET /path/to/rss1/../rss2
It would make sense to normalize this url and instead request GET /path/to/rss2.
This can easily achieved by using new WHATWG URL API.
new URL(url) will normalize url.

Example 2. brq({ host: 'example.com', path: '/path/to/rss1/../rss2' });

This won't use url.parse method, it will just use this path as is.


This is the best place to do this adjustments even though I had trouble with bcurl when I tried to resolve url /wallet/../rescan. But that worked before, because of bweb.


bweb previously was resolving paths with Path.normalize (which was causing problems to Windows users), even though it was receiving request: GET /wallet/../rescan.
Now we just remove .. from path (that's okay, if brq requests urls correctly), while it would also make sense to redirect users or just ignore those requests, or resolve it for them on bweb, that's not a big problem. Probably brq is the best place to fix this issue, even though bweb could have better behavior.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.