Cookies
Request and Response objects know about HTTP cookies, and will automatically extract and set headers for them as needed.
Cookies in response
GET
/
HTTP/1.1
Accept: */*
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Host: example.com
User-Agent: Mozilla/5.0
HTTP/1.1
200
OK
Content-Type: text/plain
Set-Cookie: app_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFVG86HV; path=/; secure; HttpOnly
Hello world!
response = RestMan.get "http://example.com/"
response.cookies["app_session"] #=> BAh7B0kiD3Nlc3Npb25faWQGOgZFVG86HV
response = RestMan::Request.execute(
method: :get,
url: "http://example.com/"
)
response.cookies["app_session"] #=> BAh7B0kiD3Nlc3Npb25faWQGOgZFVG86HV
resource = RestMan::Resource.new("http://example.com/")
resposne = resource.get
response.cookies["app_session"] #=> BAh7B0kiD3Nlc3Npb25faWQGOgZFVG86HV
RestMan doesn't support check cookies currently.
Request with cookies
POST
/resource
HTTP/1.1
Accept: */*
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Host: example.com
User-Agent: Mozilla/5.0
Content-Type: text/plain
Content-Length: 14
Cookie: app_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFVG86HV
Hello, world!
HTTP/1.1
200
OK
Content-Type: text/plain
Set-Cookie: app_session=c8y36ZmP1K0kiD3Nlc1Npb25faWQGOgZTVG86
Text received.
response = RestMan.post(
"http://example.com/resource",
"Hello, world!",
{
content_type: "text/plain",
cookie: "BAh7B0kiD3Nlc3Npb25faWQGOgZFVG86HV"
}
)
response.cookies["app_session"] #=> c8y36ZmP1K0kiD3Nlc1Npb25faWQGOgZTVG86
response = RestMan::Request.execute(
method: :post,
url: "http://example.com/resource",
payload: "Hello, world!",
headers: {
content_type: "text/plain",
cookie: "BAh7B0kiD3Nlc3Npb25faWQGOgZFVG86HV"
}
)
response.cookies["app_session"] #=> c8y36ZmP1K0kiD3Nlc1Npb25faWQGOgZTVG86
resource = RestMan::Resource.new("http://example.com/resource")
resposne = resource.post(
"Hello, world!",
{
content_type: "text/plain",
cookie: "BAh7B0kiD3Nlc3Npb25faWQGOgZFVG86HV"
}
)
response.cookies["app_session"] #=> c8y36ZmP1K0kiD3Nlc1Npb25faWQGOgZTVG86
RestMan CLI hasn't support set custom cookie currently.