diff --git a/docs/guide/advanced.md b/docs/guide/advanced.md index a927fa9..bba563d 100644 --- a/docs/guide/advanced.md +++ b/docs/guide/advanced.md @@ -16,10 +16,10 @@ local session = http.Session() session.cookies:insert("sessioncookie", "123456789", {domain="httpbin.org", path="/cookies"}) -- add new cookie to httpbin.org/cookies local r = session:get("https://httpbin.org/cookies") -print(r.content) +print(r.text) -- {"cookies": {"sessioncookie": "123456789"}} -print(session:get("https://httpbin.org/").content) -- cookies will only be sent to their set path +print(session:get("https://httpbin.org/").text) -- cookies will only be sent to their set path -- {"cookies": {}} ``` @@ -55,11 +55,11 @@ using a session. This example will only send cookies with the first request: local session = http.Session() local r = session:get("https://httpbin.org/cookies", { cookies={["temp"] = "value"} }) -print(r.content) +print(r.text) -- {"cookies": {"temp": "value"}} local r2 = session:get("https://httpbin.org/cookies") -print(r2.content) +print(r2.text) -- {"cookies": {}} ``` @@ -85,7 +85,7 @@ When handling `Request` objects directly, you can send them in a separate thread ```lua function cb(response) - print(response.content) + print(response.text) -- do stuff end diff --git a/docs/guide/quickstart.md b/docs/guide/quickstart.md index 41f2b71..f4fe4eb 100644 --- a/docs/guide/quickstart.md +++ b/docs/guide/quickstart.md @@ -58,11 +58,11 @@ Requests makes it easy to read different kinds of response content. ```lua local r = http.get("https://api.github.com/orgs/Roblox/repos") -print(r.content) +print(r.text) -- [{"id":10803524,"node_id":"MDEwOlJlcG9zaXRvcnkxMD... ``` -The `content` attribute provides the plaintext response body, regardless of the given content-type. +The `text` attribute provides the plaintext response body, regardless of the given content-type. If you'd like to decode JSON data, you can use the `:json()` method: ```lua @@ -75,7 +75,7 @@ print(#repos) In the case that JSON decoding fails, an exception will be raised. It should be noted, however, that a successful `:json()` call does **not** indicate the success of the response. Some servers may return a JSON object in a failed response, such as error details. -To check that a response is successful, use `r.success` or `r.code`. +To check that a response is successful, use `r.ok` or `r.status_code`. ### Response Headers @@ -123,7 +123,7 @@ To include custom cookies in a request, use the `cookies` option: ```lua local r = http.get("http://httpbin.org/cookies", { cookies={a=1, b=2} }) -print(r.content) +print(r.text) -- { -- "cookies": { -- "a": "1", @@ -141,7 +141,7 @@ encoded when the request is made: local payload = {key1 = "value1", list={"a", "b", "c"}} local r = http.post("https://httpbin.org/post", { data=payload }) -print(r.content) +print(r.text) -- { -- ... -- "json": { @@ -182,7 +182,7 @@ To use a form in a POST request, just set it as the `data` option: local form = http.FormData({"key", "value"}, {"key2", "value2"}) local r = http.post("https://httpbin.org/post", { data=form }) -print(r.content) +print(r.text) -- { -- ... -- "form": { @@ -214,7 +214,7 @@ Binary files can also be uploaded. This example downloads an image then uploads ```lua local image_url = "https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg" -local image = http.File("example.jpg", http.get(image_url).content) +local image = http.File("example.jpg", http.get(image_url).text) local form = http.FormData() form:AddField("file", image) @@ -240,7 +240,7 @@ We can check the response status code and message: local r = http.get("https://httpbin.org/get") print(r.code, r.message) -- 200 OK -print(r.success) +print(r.ok) -- true ``` diff --git a/docs/index.md b/docs/index.md index 7b1f0da..2bb40db 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,8 +5,7 @@ With Requests you can send robust, human-readable HTTP requests without ever having to deal with the underlying HttpService. No more manual query strings or encoding POST data. -#### The Power of Roblox Requests: - +**The Power of Roblox Requests:** ```lua local r = http.get("https://api.github.com/orgs/Roblox/repos") diff --git a/http.rbxm b/http.rbxm index 8f80e7c..9eaa917 100644 Binary files a/http.rbxm and b/http.rbxm differ