GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - httprb/form_data: Utility-belt to build form data request bodies.

BranchesTags
Open more actions menu

Latest commit

 

History

163 Commits
163 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.rubocop
.rubocop
 
 
duel
duel
 
 
lib/http
lib/http
 
 
sig
sig
 
 
test
test
 
 
.duel.rb
.duel.rb
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.mutant.yml
.mutant.yml
 
 
.rubocop.yml
.rubocop.yml
 
 
.yardopts
.yardopts
 
 
CHANGELOG.md
CHANGELOG.md
 
 
Gemfile
Gemfile
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
Steepfile
Steepfile
 
 
http-form_data.gemspec
http-form_data.gemspec
 
 

Repository files navigation

HTTP::FormData

Gem Version Test Lint Type Check Mutant Docs Duel

Utility-belt to build form data request bodies.

Installation

Add this line to your application's Gemfile:

gem 'http-form_data'

And then execute:

$ bundle

Or install it yourself as:

$ gem install http-form_data

Usage

require "http/form_data"

form = HTTP::FormData.create({
  :username     => "ixti",
  :avatar_file  => HTTP::FormData::File.new("/home/ixti/avatar.png")
})

# Assuming socket is an open socket to some HTTP server
socket << "POST /some-url HTTP/1.1\r\n"
socket << "Host: example.com\r\n"
socket << "Content-Type: #{form.content_type}\r\n"
socket << "Content-Length: #{form.content_length}\r\n"
socket << "\r\n"
socket << form.to_s

It's also possible to create a non-file part with Content-Type:

form = HTTP::FormData.create({
  :username     => HTTP::FormData::Part.new('{"a": 1}', content_type: 'application/json'),
  :avatar_file  => HTTP::FormData::File.new("/home/ixti/avatar.png")
})

Supported Ruby Versions

This library aims to support and is tested against the following Ruby versions:

  • Ruby 3.2
  • Ruby 3.3
  • Ruby 3.4
  • Ruby 4.0

If something doesn't work on one of these versions, it's a bug.

This library may inadvertently work (or seem to work) on other Ruby versions, however support will only be provided for the versions listed above.

If you would like this library to support another Ruby version or implementation, you may volunteer to be a maintainer. Being a maintainer entails making sure all tests run and pass on that implementation. When something breaks on your implementation, you will be responsible for providing patches in a timely fashion. If critical issues for a particular implementation exist at the time of a major release, support for that Ruby version may be dropped.

Contributing

  1. Fork it ( https://github.com/httprb/form_data.rb/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Copyright

Copyright (c) 2015-2026 Alexey V Zapparov. See LICENSE.txt for further details.

About

Utility-belt to build form data request bodies.

Resources

Readme
MIT license
Activity
Custom properties

Stars

35 stars

Watchers

2 watching

Forks

20 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.