Facebook

HTTP Status Code for newbies



If you are having hard time understanding or remembering HTTP codes then this article is for you.


credit - monkeyuser.com


301 Moved Permanently

The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.
The new permanent URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).


305 Use Proxy

The requested resource MUST be accessed through the proxy given by the Location field. The Location field gives the URI of the proxy. The recipient is expected to repeat this single request via the proxy. 305 responses MUST only be generated by origin servers.


307 Temporary Redirect

The requested resource resides temporarily under a different URI. Since the redirection MAY be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.


400 Bad Request

The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.


404 Not Found

The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.


408 Request Timeout

The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time.


413 Request Entity Too Large

The server is refusing to process a request because the request entity is larger than the server is willing or able to process. The server MAY close the connection to prevent the client from continuing the request.
If the condition is temporary, the server SHOULD include a Retry- After header field to indicate that it is temporary and after what time the client MAY try again.


417 Expectation Failed

The expectation given in an Expect request-header field (see section 14.20) could not be met by this server, or, if the server is a proxy, the server has unambiguous evidence that the request could not be met by the next-hop server.


500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.



How to shorten the bash shell prompt


So sometimes it happens that you are working on command terminal and you navigate inside a directory then again in inner directory and so on until half of the screen width is filled with prompt string. Example below....

rana@Brahma: dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8 $ ls 

Now I want to display just the last directory in terminal prompt string so that I am left with enough width space to execute length commands.

For this We need to change the prompt string from .bashrc file. Below are the steps -

1. Go to your home directory.
2. Open .bashrc file.
3. Search for string 'PS1'. To search quick open the file in vi and type /PS1 and hit enter.
4. now you will find below code. (or similar to it) [ I am working on Ubuntu 16.04]
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
5. Replace the 'w' (highlighted in blue color) with capital W. So your new code will be.
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]: \[\033[01;34m\]\W\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
6. Restart the terminal and navigate inside any directory. You will see just the last directory in teminal prompt.
rana@Brahma: dir8$

Happy Learning.