Skip to content

Commit

Permalink
updated http.rbxm
Browse files Browse the repository at this point in the history
  • Loading branch information
jpatrickdill committed May 18, 2020
1 parent 28603a4 commit 15a9aec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
10 changes: 5 additions & 5 deletions docs/guide/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}}

```
Expand Down Expand Up @@ -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": {}}
```

Expand All @@ -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

Expand Down
16 changes: 8 additions & 8 deletions docs/guide/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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",
Expand All @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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)
Expand All @@ -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
```

Expand Down
3 changes: 1 addition & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Binary file modified http.rbxm
Binary file not shown.

0 comments on commit 15a9aec

Please sign in to comment.