Revolutionize Your HTTP Requests with mruby-smallhttp

Hi there,

I have updated your article for you. I hope you like it.

Introducing Mruby-Smallhttp: A Simple HTTP-Client Library

While working on my Telegram API library, I ran into a problem finding a good HTTP-client library that could handle multipart/form-data requests. I also found that some libraries required me to form the body of the requests myself, which was time-consuming and not very efficient.

I decided to solve this problem and wrote a library that is a small, less than 200 lines of code, HTTP-client library. While there are still some small issues that need fixing, I believe this library is a great start, and I am hoping for contributions from the community to make it even better.

So, let me introduce you to Mruby-Smallhttp.

Installing Mruby-Smallhttp

Installing Mruby-Smallhttp is a simple and straightforward process. Here are the steps to follow:

  • Add the following line to your build_config.rb file: do |conf|
  conf.gem :mgem => 'mruby-smallhttp'

And you’re done! It’s that simple.

How to Use Mruby-Smallhttp

Using Mruby-Smallhttp is also very easy. Here are some examples of how to use it:

Making GET Requests

# GET Request"").get
#=> response

Making POST Requests

data = { name: 'value' }
headers = {'Content-Type' => 'application/json'}"").post(data, headers)
#=> response

Making PUT Requests

http ="")
http.put(data, headers)

Making DELETE Requests

http ="")
http.delete(data, headers)
#=> response

Making HEAD & OPTIONS Requests

http ="")
http.request("HEAD", body, header)
#=> response

Sending Files

If you need to send a file in your POST request, here’s how to do it:

body = { name: 'value', file:'filename') }
header = { 'Content-Type' => 'multipart/form-data' }
http =""), header)
#=> response

Content-Type supported: application/json, application/x-www-form-urlencoded, multipart/form-data.


Mruby-Smallhttp is a simple, lightweight HTTP-client library that can handle different types of requests, including multipart/form-data requests. Although it’s still a work in progress, I am confident that it will be a great addition to your toolbox. If you’re interested in contributing to the project, please visit the Mruby-Smallhttp Github page to get started.

Thank you for reading!