Coder Social home page Coder Social logo

jpatrickdill / roblox-requests Goto Github PK

View Code? Open in Web Editor NEW
33.0 33.0 7.0 2.24 MB

The simple, elegant way to send HTTP requests in Roblox.

Home Page: https://requests.paric.xyz/

License: MIT License

Lua 100.00%
http httpservice lua rbxdev roblox roblox-requests

roblox-requests's Introduction

roblox-requests's People

Contributors

jpatrickdill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

roblox-requests's Issues

multipart/form-data includes one too many \r\n

Describe the bug
FormData:build() (in form.lua) builds the multipart/form-data content_type with just one too many \r\n beteen each part.

To Reproduce
Send a POST request using a FormData object which includes a File object so multipart/form-data is used. See this example code that uses https://httpbin.org/anything (echos back data about the request):

-- Two similar requests, however the latter also sends a file
print(http.post("https://httpbin.org/anything", {
	data = http.FormData({
		hello = "Hello, world";
	});
}):json())
print(http.post("https://httpbin.org/anything", {
	data = http.FormData({
		hello = "Hello, world";
		a_random_file = http.File("hello.txt", "Hello, world in a file", "\n");
	})
}):json())

Example results from Roblox Studio's Output window. Observe the "form" JSON key returned by httpbin - the "hello" key in the second request which includes a file has a preceding newline character. Oh dear!

  Baseplate auto-recovery file was created - C:/Users/Ozzy/Documents/ROBLOX/AutoSaves
  [http] 200 OK | POST https://httpbin.org/anything ( 0.1% ratelimit ) - request:204
   ▼  {
    ["args"] = {},
    ["data"] = "",
    ["files"] = {},
    ["form"] =  ▼  {
       ["hello"] = "Hello, world"
    },
    ["headers"] =  ▶ {...},
    ["method"] = "POST",
    ["origin"] = "23.121.92.239",
    ["url"] = "https://httpbin.org/anything"
  } - Script:31
  [http] Encoding B64 chunk 1/1 - b64:54
  [http] 200 OK | POST https://httpbin.org/anything ( 0.2% ratelimit ) - request:204
   ▼  {
    ["args"] = {},
    ["data"] = "",
    ["files"] =  ▶ {...},
    ["form"] =  ▼  {
       ["hello"] = "
Hello, world"
    },
    ["headers"] =  ▶ {...},
    ["method"] = "POST",
    ["origin"] = "23.121.92.239",
    ["url"] = "https://httpbin.org/anything"
  } - Script:37

Expected behavior
We expect the form data sent (and thereby echoed by httpbin) to not include any extra content we didn't actually send.

Screenshots
The output from above as viewed from Roblox Studio's Output window.
https://i.imgur.com/zCAMTaa.png

Additional context
Methinks this was just a small typo. Gonna submit a PR which removes the extra 2 bytes in the string on line 163 and fixes the issue momentarily.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.