Code Monkey home page Code Monkey logo

centra's Introduction

Hello, Ethan here. My primary language is Go, and I am well acquainted with others. I like working on network protocols, storage formats, and high-quality libraries.

centra's People

Contributors

asaianudeep avatar ethanent avatar heath123 avatar jdforsythe avatar jmcdo29 avatar wision avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

centra's Issues

IPv6 with brackets causes a DNS error

Bug Description

When working with pactum for E2E testing and NestJS for the HTTP server framework, I ran into a bug when trying to make a request to http://[::1]:3000 about [::1] not being as found address. After digging in more I found that pactum uses phin and phin uses centra.

Current Behavior

You can run the following in a Node REPL. I'll make a full minimum reproduction repository if you'd like me to as well ๐Ÿ˜„

centra('http://[::1]:3000').send().then(console.log)

And receive the error

Uncaught Error: getaddrinfo ENOTFOUND [::1]
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)
    at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: '[::1]'
}

Expected Behavior

I should be able to make an HTTP request using an IPv6 with brackets separating the host and the port

Proposed Solution

The reason for this error is due to the URL.hostname property. The hostname itself should resolve to ::1 instead of [::1] as described in this issue on the Node repo. For node 15+ we can use urlToHttpOptions() from the url package instead of using Object.assign() on line 109 onf CentraRequest.js. However, if support for Node 12 and 14 is still required, we can do two replaces for the [ and ] characters, as they're not valid http host characters anyways.

I'm more than happy to implement this, just need to know which approach you'd prefer

Other information

Node: 16.13.0

Streaming uploads

It would be helpful for requests to support a Stream as the request body. I believe this is actually fairly simple, in that the query function needs to distinguish a StreamReader parameter and then send needs to use Stream.pipeline to connect the reader and request writer. Node.js' HTTP does the chunking automatically. At least that's my theory of how it would work ;-)
NB: I was trying to use phin, so ensuring phin can use this would be good too, I believe it just passes the data field through, so that should be automatic.

buffers

currently im trying to buffer an image,
const req = require('centra') const code = encodeURIComponent(err) const img = await req(https://zakazar.herokuapp.com/code-img/` + code)
`
how to i turn this into a buffer?
the api returns an image of the code i input
image as an example

TypeError: URL is not a constructor occurs when using React

We tried using centra for our HTTP requests in a React application but then a TypeError occurs and we cannot make any request.

I already saw there was a similar issue but with browserify. Is there maybe any connection with fixing the error?

grafik

What we use:
node - v14.15.3
centra - 2.4.2
react - 17.0.1

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.