R: Base response object

HttpResponse {crul} | R Documentation

## Base response object

### Description

Base response object

### Arguments

`url` | (character) A url, required
`opts` | (list) curl options
`handle` | A handle
`method` | (character) HTTP method
`status_code` | (integer) status code
`request_headers` | (list) request headers, named list
`response_headers` | (list) response headers, named list
`modified` | (character) modified date
`times` | (vector) named vector
`content` | (raw) raw binary content response
`request` | request object, with all details

### Details

Methods

`parse()`

  Parse the raw response content to text

`success()`

  Was status code less than or equal to 201. returns boolean

`status_http()`

  Get HTTP status code, message, and explanation

`raise_for_status()`

  Check HTTP status and stop with appropriate HTTP error code and message if >= 300. - If you have `fauxpas` installed we use that, otherwise use httpcode

### Examples

    ## Not run:
    x <- HttpResponse$new(method = "get", url = "https://httpbin.org")
    x$url
    x$method

    x <- HttpClient$new(url = 'https://httpbin.org')
    (res <- x$get('get'))
    res$request_headers
    res$response_headers
    res$parse()
    res$status_code
    res$status_http()
    res$status_http()$status_code
    res$status_http()$message
    res$status_http()$explanation
    res$success()

    x <- HttpClient$new(url = 'https://httpbin.org/status/404')
    (res <- x$get())
    # res$raise_for_status()

    x <- HttpClient$new(url = 'https://httpbin.org/status/414')
    (res <- x$get())
    # res$raise_for_status()

    ## End(Not run)

[Package crul version 0.6.0 Index]