ethanent / centra Goto Github PK
View Code? Open in Web Editor NEWCore Node.js HTTP client
License: MIT License
Core Node.js HTTP client
License: MIT License
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
as an example
Since there are already great libraries out there solving this very problem, it would be useful to know yr motivation to create this project.
Good luck!
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.
querystring in Node.js (latest) is marked as legacy support, while it's still being maintained, it's recommended to avoid using querystring where possible. In fact VSCode marked querystring as deprecated to use.
https://nodejs.org/api/querystring.html
Requested originally in Phin: ethanent/phin#56
Hello. Is there a reason, why content-length
header is set only for form
data? Thanks.
Centra uses the http package (in CentraRequest.js) but this package seems to have been removed because it contained malicious code : see this page.
What am I supposed to do to use Centra ?
Ethan made this repo, which means it is either a clone of something that already exists or he spent 15 minutes on it. I suspect it is the latter.
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.
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]'
}
I should be able to make an HTTP request using an IPv6 with brackets separating the host and the port
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 replace
s 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
Node: 16.13.0
See ethanent/phin#59
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.