Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HTML error responses #130

Open
nikola-mladenovic opened this issue Mar 22, 2017 · 4 comments
Open

Support HTML error responses #130

nikola-mladenovic opened this issue Mar 22, 2017 · 4 comments
Assignees

Comments

@nikola-mladenovic
Copy link
Contributor

An example HTML error response that should be supported:

15:11 $ curl -v -XPOST ***.com
* Rebuilt URL to: ***.com/
*   Trying 35.186.251.105...
* Connected to ***.com (***) port 80 (#0)
> POST / HTTP/1.1
> Host: ***.com
> User-Agent: curl/7.43.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 411 Length Required
< Content-Type: text/html; charset=UTF-8
< Content-Length: 1564
< Date: Wed, 22 Mar 2017 14:11:13 GMT
<
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 411 (Length Required)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>411.</b> <ins>That’s an error.</ins>
  <p>POST requests require a <code>Content-length</code> header.  <ins>That’s all we know.</ins>
* Closing connection 0
@nikola-mladenovic nikola-mladenovic self-assigned this Mar 22, 2017
@nikola-mladenovic
Copy link
Contributor Author

Currently, when the HTML response is received the following error will be passed to the client: AFError.ResponseSerializationFailureReason.jsonSerializationFailed

@nikola-mladenovic
Copy link
Contributor Author

In order to change this, we would need to stop using responseJSON (which gives us automatic JSON response serialization) Alamofire method calls from all of our endpoints. Instead, we'd manually process the HTTPURLResponse and use JSONSerialization or just return the plain HTML body if the LB returned an error.

@cneijenhuis - do you think we should proceed?

@cneijenhuis
Copy link

This looks like a bigger refactoring, and we've currently got more valuable tasks we can spend this time on.

Also, I still hope that the Google Cloud LB will implement JSON responses for clients that request JSON. It seems like a quite basic feature for a Load Balancer for APIs...

Let's keep this issue open though, and we may re-prioritize this in the future.

@nikola-mladenovic
Copy link
Contributor Author

Agreed, thank you! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants