Skip to content

HTTP status logic is inadequate #38

@rickb777

Description

@rickb777

There is a major bug: the status code can get ignored, doesn't handle 3xx and is not available to client code.

  • Redirects are not handled.
  • Conditional requests are impossible.
  • Depending on usage, client or server errors can get ignored.

Typically, all you get back is a Jackson exception because the error page cannot be parsed; this is quite unsatisfactory.

For example in https://github.com/hmrc/http-verbs/blob/master/src/main/scala/uk/gov/hmrc/play/http/HttpGet.scala

def GET[A](url: String)(implicit rds: HttpReads[A], hc: HeaderCarrier): Future[A] =
  withTracing(GET_VERB, url) {
    val httpResponse = doGet(url)
    executeHooks(url, GET_VERB, None, httpResponse)
    mapErrors(GET_VERB, url, httpResponse).map(response => rds.read(GET_VERB, url, response))
  }

should probably be more like

def GET[A](url: String)(implicit rds: HttpReads[A], hc: HeaderCarrier):
        Future[Either[HttpResponse, A]] =
  withTracing(GET_VERB, url) {
    val httpResponse = doGet(url)
    executeHooks(url, GET_VERB, None, httpResponse)
    mapErrors(GET_VERB, url, httpResponse).<... rewrite this ...>
  }

The same applies to the other methods, POST, PUT etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions