Some of examples requires mruby-uv
This uses joyent's http-parser
MIT
interface to http for mruby(experimental)
Home Page: http://mattn.kaoriya.net/
Some of examples requires mruby-uv
This uses joyent's http-parser
MIT
Hi!
Thanks for the module!
I found that HTTP::URL::decode has some bugs that will cause memory corruption
around line 588
while (_pstr) {
if (_pstr == '%') {
if (pstr[1] && pstr[2]) {
In both cases it may overflow the destination buffer.
Take a look at
https://code.google.com/p/stringencoders/source/browse/trunk/src/modp_burl.c
around line 220
for a safe way of doing this.
I'll try and make a patch later today.
nickg
Hi, @mattn
mruby-http is very useful. I have a question.
res_text1 = "HTTP/1.1 301 Moved Permanently\r\nServer: nginx\r\nDate: Sun, 11 May 2014 15:16:39 GMT\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: 0\r\nConnection: keep-alive\r\nX-Pingback: http://blog.matsumoto-r.jp/xmlrpc.php\r\nLocation: http://blog.matsumoto-r.jp/\r\n\r\n"
res_text2 = "HTTP/1.1 301 Moved Permanently\r\nServer: nginx\r\nDate: Sun, 11 May 2014 15:16:39 GMT\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: 0\r\nConnection: keep-alive\r\nX-Pingback: http://blog.matsumoto-r.jp/xmlrpc.php\r\nLocation: http://blog.matsumoto-r.jp/\r\n\r\nbody\n"
res_text3 = "HTTP/1.1 200 OK\r\nDate: Sun, 11 May 2014 15:23:44 GMT\r\nServer: Apache/2.4.7 (Ubuntu)\r\nLast-Modified: Sun, 11 May 2014 08:13:49 GMT\r\nETag: \"e-4f91b691fc8b7\"\r\nAccept-Ranges: bytes\r\nContent-Length: 14\r\nContent-Type: text/html\r\n\r\nupstream dayo\n"
p HTTP::Parser.new.parse_response res_text1
p HTTP::Parser.new.parse_response res_text2
p HTTP::Parser.new.parse_response res_text3
[[email protected]_64:~/DEV/mruby]$ ./bin/mruby http.rb
#<HTTP::Response:0x15051a0 method="GET", body=nil, headers={}>
#<HTTP::Response:0x1504ea0 method="GET", body="body\n", headers={}>
#<HTTP::Response:0x1504c30 method="DELETE", headers={"Date"=>"Sun, 11 May 2014 15:23:44 GMT", "Server"=>"Apache/2.4.7 (Ubuntu)", "Last-Modified"=>"Sun, 11 May 2014 08:13:49 GMT", "ETag"=>"\"e-4f91b691fc8b7\"", "Accept-Ranges"=>"bytes", "Content-Length"=>"14", "Content-Type"=>"text/html"}, body="upstream dayo\n", status_code=200, content_length=0>
Is this a specification or bug of mruby-http? At least, content_length=0
is wrong.
When the response headers have a repeated field (2 or more times) only the value for the last repeated field is set. This is because of a hash (in ruby) cannot have a repeated key (header field). there's any work arround?,
Thanks!.
I get the following warning when compiling mruby-http
:
/home/mruby/code/mruby/build/mrbgems/mruby-http/src/mrb_http.c:47:35: warning: unused variable 'http_url_type' [-Wunused-const-variable]
static const struct mrb_data_type http_url_type = {
/home/mruby/code/mruby/build/mrbgems/mruby-http/src/mrb_http.c:490:1: warning: 'mrb_http_object_headers_set_item' defined but not used [-Wunused-function]
mrb_http_object_headers_set_item(mrb_state *mrb, mrb_value self)
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.