I am creating a webpage for another company. If this website is created wrong or if there is any errors I can't sell it to the company. I know there is several types of http status codes. I know for example there is the 404 error when the address is wrong but I don't know any of the other http status codes. Can anybody please tell me what they are?
EDIT:
I also want to know wich can be styled by me. So for example a 404 status code can be styled on my own way by saying the location of my document in an .htaccess file
You'll find a full list of HTTP status codes here:
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
Are you looking for http status codes? If yes, Please check this wiki link http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
All the possible codes. Mostly for handling error scenarios we care about 400 and 500 series.
Solution:
check the http response code belongs to 400 or 500 series, if yes then redirect the page to some error page defining the error message what went wrong or define some custom messages to show to client (more meaningful to end users). That way the application would handle error scenarios gracefully.
-> 100:
return "Continue";
-> 101:
return "Switching Protocols";
-> 102:
return "Processing (WebDAV)";
-> 200:
return "OK";
-> 201:
return "Created";
-> 202:
return "Accepted";
-> 203:
return "Non-Authoritative Information";
-> 204:
return "No Content";
-> 205:
return "Reset Content";
-> 206:
return "Partial Content";
-> 207:
return "Multi-Status (WebDAV)";
-> 300:
return "Multiple Choices";
-> 301:
return "Moved Permanently";
-> 302:
return "Found";
-> 303:
return "See Other";
-> 304:
return "Not Modified";
-> 305:
return "Use Proxy";
-> 307:
return "Temporary Redirect";
-> 400:
return "Bad Request";
-> 401:
return "Unauthorized";
-> 402:
return "Payment Required";
-> 403:
return "Forbidden";
-> 404:
return "Not Found";
-> 405:
return "Method Not Allowed";
-> 406:
return "Not Acceptable";
-> 407:
return "Proxy Authentication Required";
-> 408:
return "Request Time-out";
-> 409:
return "Conflict";
-> 410:
return "Gone";
-> 411:
return "Length Required";
-> 412:
return "Precondition Failed";
-> 413:
return "Request Entity Too Large";
-> 414:
return "Request-URI Too Large";
-> 415:
return "Unsupported Media Type";
-> 416:
return "Requested range not satisfiable";
-> 417:
return "Expectation Failed";
-> 422:
return "Unprocessable Entity (WebDAV)";
-> 423:
return "Locked (WebDAV)";
-> 424:
return "Failed Dependency (WebDAV)";
-> 500:
return "Internal Server Error";
-> 501:
return "Not Implemented";
-> 502:
return "Bad Gateway";
-> 503:
return "Service Unavailable";
-> 504:
return "Gateway Time-out";
-> 505:
return "HTTP Version not supported";
-> 507:
return "Insufficient Storage (WebDAV)";
-> 510:
return "Not Extended";
There is a few places to look at:
HTTP Status Code Errors,
List of HTTP status codes - Wikipedia
HTTP Error and Status Codes Explained
100-199 : informational status
200-299 : success status
300-399 : redirection status
400-499 : client errors
500-599 : server errors
Actually it's just the 400-500 codes that's important. Others is also important but not as important.
Related
I have a Go app that connects with a postgres database through the driver called "github.com/lib/pq".
I make a connection with a database called godb, and the function Open() works correctly, but when I check errors with db.Ping(), it tells me the database doesn´t exist, although I have created it in pg Admin and the name and the password are well written. I have tried to check if the connection string is correct, I have tried to create a new database and connect it but it gives the same error. I have also tried to disconnect and reconnect the database and it doesn't work.
package main
import (
"database/sql"
"fmt"
"log"
"sync"
//driver of the database
_ "github.com/lib/pq"
)
var (
db *sql.DB
once sync.Once
)
func NewPostgresDB() {
once.Do(func() {
var err error
db, err = sql.Open("postgres",
"postgres://postgres:/*password of the database*/#localhost:5432/godb?sslmode=disable")
if err != nil {
log.Fatalf("There is an error in the connction string %v", err)
}
if err = db.Ping(); err != nil {
log.Fatalf("There was an error connecting to the database %v", err)
}
})
fmt.Println("connection succeeded")
}
this is the error it exactly returns (it's in Spanish):
pq: no existe la base de datos �godb�
exit status 1
We are trying to upload files into Google Cloud Storage before moving them into BigQuery, but we are often facing '500 Internal Server Error' or '410 Gone' (raw messages below) during some uploads.
We are using the official SDK and have added retry with exponential backoff but the errors are always here. Do you have any advise please ?
Here is how we upload (scala) :
val credential = new GoogleCredential().setAccessToken(accessToken)
val requestInitializer = new HttpRequestInitializer() {
def initialize(request: HttpRequest): Unit = {
credential.initialize(request)
// to avoid read timed out exception
request.setConnectTimeout(200000)
request.setReadTimeout(200000)
request.setIOExceptionHandler(new
HttpBackOffIOExceptionHandler(new ExponentialBackOff()))
request.setUnsuccessfulResponseHandler(new
HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()))
}
}
val storage = new Storage.Builder(
new NetHttpTransport,
JacksonFactory.getDefaultInstance,
requestInitializer
).setApplicationName("MyAppHere").build
val objectMetadata = new StorageObject()
.setBucket(bucketName)
.setName(distantFileName)
val isc = new InputStreamContent("binary/octet-stream", fis)
val length = isc.getLength
val insertObject = storage.objects().insert(bucketName, objectMetadata, isc)
// For small files, you may wish to call setDirectUploadEnabled(true), to
// reduce the number of HTTP requests made to the server.
if (length > 0 && length <= 2 * 1000 * 1000 /* 2MB */ ) {
insertObject.getMediaHttpUploader.setDirectUploadEnabled(true)
}
insertObject.execute()
Our scala dependancies :
"com.google.api-client" % "google-api-client" % "1.18.0-rc",
"com.google.api-client" % "google-api-client-jackson2" % "1.18.0-rc",
"com.google.apis" % "google-api-services-bigquery" % "v2-rev142-1.18.0-rc",
"com.google.apis" % "google-api-services-storage" % "v1-rev1-1.18.0-rc",
"com.google.http-client" % "google-http-client" % "1.18.0-rc",
"com.google.oauth-client" % "google-oauth-client" % "1.18.0-rc"
Raw SDK error responses :
500 Internal Server Error
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Backend Error",
"reason" : "backendError"
} ],
"message" : "Backend Error"
}
410 Gone
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Backend Error",
"reason" : "backendError"
} ],
"message" : "Backend Error"
}
Every Backend error should be handled with an exponential retry, as there might be service problems.
If the error still persists after let's say 10 hours then you should contact the support in order to provide you 1:1 help to your problem.
When I execute, I am getting an error: 64x/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/Kernel_require.rb:54:in 'require': Cannot load such file
require "net/http"
require "uri"
require "nokogiri"
uri = URI.parse("http://www.google.com")
response = Net::HTTP.get_response(uri)
puts parse_body(response.body)
def parse_body(response)
begin
return Nokogiri::XML(response) { |config| config.strict }
rescue Nokogiri::XML::SyntaxError => e
return "caught exception: #{e}"
end
end
Try using require_relative generally when ever you get this issue. (not the best way though!)
Try this
$:.unshift File.join(File.dirname(__FILE__), ".")
Trying to remove a cookie only if the url is not like "demo/secured"
In the default.vcl I have:
sub vcl_fetch {
# error 200 req.url ~ ".*/demo/secured/.*";
if (req.url ~ ".*/demo/secured/.*") {
set beresp.http.x-whaaat = "this is demo securd";
}else {
unset beresp.http.set-cookie;
set beresp.http.x-whaaat = "not demo secured";
}
}
Both url's with or without /demo/secured result in a x-whaaat response header of "not demo secured". But uncommenting the error 200 line gives error 200 true for url's with demo/secured and error 200 false for url's without demo/secured.
I tried a gazillion and one variations of that if statement but can't get it to return anything other than false.
The following is true:
if ( "/app_dev.php/demo/secured/login" ~ ".*/demo/secured/.*" )
Even though I copied and pasted "/app_dev.php/demo/secured/login" from the page output of error 200 req.url the following isn't true:
# error 200 req.url;
if ( req.url ~ ".*/demo/secured/.*" ) {
set beresp.http.x-whaaat = "this is demo securd";
}else {
unset beresp.http.set-cookie;
set beresp.http.x-whaaat = "not demo secured";
}
gives me a "x-whaat not demo secured" header on http://site/app_dev.php/demo/secured/login not sure how this is possible because the same url gives me "/app_dev.php/demo/secured/login" when uncommenting the error 200 line.
varnishd -V
gives me:
varnishd (varnish-3.0.5 revision 1a89b1f)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2011 Varnish Software AS
I was looking at the wrong request in firebug/chrome dev tool. The request I was inspecting was a xhr request made to mysite.com/app_dev.php/_wdt/60c03d and that doesn't have /demo/secured so sure enough it has the right headers.
Time to walk away from the computer for a while now, continue tomorrow.
App Engine does not allow use of DefaultClient, providing the urlfetch service instead. The following minimal example deploys and works pretty much as expected:
package app
import (
"fmt"
"net/http"
"appengine"
"appengine/urlfetch"
"code.google.com/p/goauth2/oauth"
)
func init () {
http.HandleFunc("/", home)
}
func home(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
config := &oauth.Config{
ClientId: "<redacted>",
ClientSecret: "<redacted>",
Scope: "email",
AuthURL: "https://www.facebook.com/dialog/oauth",
TokenURL: "https://graph.facebook.com/oauth/access_token",
RedirectURL: "http://example.com/",
}
code := r.FormValue("code")
if code == "" {
http.Redirect(w, r, config.AuthCodeURL("foo"), http.StatusFound)
}
t := &oauth.Transport{Config: config, Transport: &urlfetch.Transport{Context: c}}
tok, _ := t.Exchange(code)
graphResponse, _ := t.Client().Get("https://graph.facebook.com/me")
fmt.Fprintf(w, "<pre>%s<br />%s</pre>", tok, graphResponse)
}
With correct ClientId, ClientSecret and RedirectURL, this produces the following output (edited for brevity):
&{AAADTWGsQ5<snip>kMdjh5VKwZDZD 0001-01-01 00:00:00 +0000 UTC}
&{200 OK %!s(int=200) HTTP/1.1 %!s(int=1) %!s(int=1)
map[Connection:[keep-alive] Access-Control-Allow-Origin:[*]
<snip>
Content-Type:[text/javascript; charset=UTF-8]
Date:[Wed, 06 Feb 2013 12:06:45 GMT] X-Google-Cache-Control:[remote-fetch]
Cache-Control:[private, no-cache, no-store, must-revalidate] Pragma:[no-cache]
X-Fb-Rev:[729873] Via:[HTTP/1.1 GWA] Expires:[Sat, 01 Jan 2000 00:00:00 GMT]]
%!s(*urlfetch.bodyReader=&{[123 34 105 100 <big snip> 48 48 34 125] false false})
%!s(int64=306) [] %!s(bool=true) map[] %!s(*http.Request=&{GET 0xf840087230
HTTP/1.1 1 1 map[Authorization:[Bearer AAADTWGsQ5NsBAC4yT0x1shZAJAtODOIx0tZCb
TYTjxFC4esEqCjPDi3REMKHBUjZCX4FIKLO1UjMpJxhJZCfGFcOJlFu7UvehkMdjh5VKwZDZD]]
0 [] false graph.facebook.com map[] map[] })}
It certainly seems like I'm consistently getting an *http.Response back, so I would expect to be able to read from the response Body. However, any mention of Body--for example with:
defer graphResponse.Body.Close()
compiles, deploys, but results in the following runtime error:
panic: runtime error: invalid memory address or nil pointer dereference
runtime.panic go/src/pkg/runtime/proc.c:1442
runtime.panicstring go/src/pkg/runtime/runtime.c:128
runtime.sigpanic go/src/pkg/runtime/thread_linux.c:199
app.home app/app.go:33
net/http.HandlerFunc.ServeHTTP go/src/pkg/net/http/server.go:704
net/http.(*ServeMux).ServeHTTP go/src/pkg/net/http/server.go:942
appengine_internal.executeRequestSafely go/src/pkg/appengine_internal/api_prod.go:240
appengine_internal.(*server).HandleRequest go/src/pkg/appengine_internal/api_prod.go:190
reflect.Value.call go/src/pkg/reflect/value.go:526
reflect.Value.Call go/src/pkg/reflect/value.go:334
_ _.go:316
runtime.goexit go/src/pkg/runtime/proc.c:270
What am I missing? Is this because of the use of urlfetch rather than DefaultClient?
Okay, this was of course my own silly fault but I can see how others could fall into the same trap so here's the solution, prompted by Andrew Gerrand and Kyle Lemons in this google-appengine-go topic (thanks guys).
First of all, I wasn't handling requests to favicon.ico. That can be taken care of by following the instructions here and adding a section to app.yaml:
- url: /favicon\.ico
static_files: images/favicon.ico
upload: images/favicon\.ico
This fixed panics on favicon requests, but not panics on requests to '/'. Problem was, I'd assumed that an http.Redirect ends handler execution at that point. It doesn't. What was needed was either a return statement following the redirect, or an else clause:
code := r.FormValue("code")
if code == "" {
http.Redirect(w, r, config.AuthCodeURL("foo"), http.StatusFound)
} else {
t := &oauth.Transport{Config: config, Transport: &urlfetch.Transport{Context: c}}
tok, _ := t.Exchange(code)
fmt.Fprintf(w, "%s", tok.AccessToken)
// ...
}
I don't recommend ignoring the error of course but this deploys and runs as expected, producing a valid token.