creationix / seaduk

An implementation of nucleus-js using duktape and libuv implemented in C
Other
34 stars 5 forks source link

Implement a request like library (or port dukcurl) #7

Open FreshXOpenSource opened 8 years ago

FreshXOpenSource commented 8 years ago

One big feature yet missing from the legacy duv implementation is the ability to make http(s) client requests. im not sure how nasty the original implementation was and if its better to avoid it but the feature is hardly missing

creationix commented 8 years ago

Http is easy enough given tls. We'll need openssl bindings or something to get tls though.

Libcurl is an option, but it's tricky to ensure it's non-blocking.

creationix commented 7 years ago

I'm starting on mbedtls bindings for duktape. Initially I'm just choosing the stuff I need for my personal project, but eventually we can add TLS support.

https://github.com/nucleus-js/seaduk/tree/mbed

FreshXOpenSource commented 7 years ago

thats excellent!

FreshXOpenSource commented 7 years ago

do you plan to implement tls basic network functions in the near future?

creationix commented 7 years ago

not near future, sorry. Life got in the way again.

FreshXOpenSource commented 7 years ago

i wrote a simple request module using the example code given in the test-apps which runs basically fine using request(url,options,callback) unless we have more than one datagram. in this case the simple client example i wrote (attached) fails like this :


Requesting  http://lorempixel.com/800/600/people/
Proto: http://  Host : lorempixel.com  Port : 80 Path : /800/600/people/
Element  Connection  already in headers
DNS lookup of lorempixel.com resolves to 2a01:488:67:1000:253d:c8bc:0:1
Connected to 2a01:488:67:1000:253d:c8bc:0:1:80
ctx: top=1, stack=[{}]
Uncaught TypeError: not buffer
    at [anon] (duk_bi_buffer.c:173) internal
    at concat () native strict preventsyield
    at concat (deps/http-codec:304) strict
    at onRead (deps/wrap-socket:50) strict preventsyield
    at [anon] () native strict preventsyield
    at global (client.js:28) preventsyield
    at [anon] () native strict preventsyield
    at eval (eval:1) preventsyield```

The type of object which it tries to concat is sometimes buffer and sometimes object. Any ideas why the types dont match?
FreshXOpenSource commented 7 years ago

request.zip