HTTP Summary

HTTP Request Methods:

GET
POST
PUT
DELETE
HEAD
TRACE
OPTIONS
CONNECT

HTTP Request Headers:

Accept
Accept-Charset
Accept-Encoding
Accept-Language
Authorization
Cookie
Expect
From
Host
If-Match
If-Modified-Since
If-None-Match
If-Range
If-Unmodified-Since
Max-Forwards
Proxy-Authorization
Range
Referer
TE
User-Agent

HTTP Response Status Codes

Informational (100-199)
Successful (200-299)
Redirection (300-399)
Client error (400-499)
Server error (500-599)

100 Continue
101 Switching Protocols

200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content

300 Multiple Choices
301 Moved Permanently
302 Found
303 See Other (302 Found | Get)
304 Not Modified
305 Use Proxy
306 * Deprecated *
307 Temporary Redirect (302 Found | same request method)

400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Timeout
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Request Entity Too Large
414 Request-URI Too Long
415 Unsupported Media Type
416 Requested Range Not Satisfiable
417 Expectation Failed

500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported

HTTP Response Headers

Accept-Ranges (bytes | none)
Age
Authentication-Info (HTTP digest authentication)
Content-Disposition (suggested filename)
ETag
Location
Proxy-Authenticate
Refresh (meta http-equiv=”refresh” content=”3; url=http://httphandbook.org/”)
Retry-After (503 or any of the 300-range (redirection) status codes)
Server
Set-Cookie
Vary (cache proxy)
WWW-Authenticate

HTTP General Headers

  • Cache-Control
HTTP Request
	no-cache (do not cache http headers specified)
	no-store (do not cache current http request & response)
	max-age
	max-stale (extend expiration date of the resource for the purpose of caching)
	min-fresh (reduce expiration date of the resource for the purpose of caching)
	no-transform (do not modify the content part of the HTTP response)
	only-if-cached (do not contact server, send cache back to client)
	cache-extension (specify not explicitly defined directives)
HTTP Response
	public (any caching by any caching system)
	private (allows caching, but not on shared caches | browser cache is private)
	no-cache
	no-store
	no-transform
	must-revalidate (must revalidate after expired)
	proxy-revalidate (must-revalidate exclude private caches)
	max-age
	s-maxage (max-age exclude private caches)
	cache-extension
  • Connection (HTTP connection management | TCP)(Keep-Alive | Close | Upgrade)
  • Date (system time when request was generated on Browser or response was generated on Server)
  • Pragma (caching in HTTP/1.0) (Pragma: no-cache) (forward request or response to server or browser)
  • Keep-Alive (maximum amount of time that the TCP connection can remain open) (require Connection general header have a value of Keep-Alive)
  • Trailer (include some HTTP headers after the content) (require Transfer-Encoding: chunked)
  • Transfer-Encoding (each piece of the content begins with a hexadecimal value of the length of the next chunk on a line by itself)
  • Upgrade (negotiate a change in protocol)
  • Via (proxies add their name to “Via” header as they forward messages)
  • Warning
	110 Response is stale
	111 Revalidation failed
	112 Disconnected operation
	113 Heuristic expiration
	199 Miscellaneous warning
	214 Transformation applied
	299 Miscellaneous persistent warning

HTTP Entity Headers

Allow
Content-Encoding (compress | deflate | gzip)
Content-Language
Content-Length (the length of the content section of the HTTP message in bytes)
Content-Location (the URL of the resource being returned differs from the URL being requested)
Content-MD5 (MD5 && Base-64 encoding)
Content-Range (Content-Range: 600-900/1234)
Content-Type (Content-Type: text/html)
Expires
Last-Modified

HTTP Formatting Specifications

Line Termination: CRLT (carriage return plus a line feed, \r\n)
Content Separation: empty line
Header Formatting: Header-Name: value
Date Formats: Tue, 21 May 2002 12:34:56 GMT
URL Encoding: ISO-Latin characters 32-126, Reserved characters is encoded as a percent sign (%), followed by the hexadecimal value of the character
HTML entities: is encoded as “&#xxx;” where xxx represents the decimal value of the character (“& a m p ;” is an ampersand)

HTTP Media Types

  • application
  • audio
  • image
  • message
  • model
  • multipart
  • text
  • video

The most current list of all registered media types can be found at http://www.iana.org/assignments/media-types/index.html

Check sql statement executed in mysql

mysql> SHOW VARIABLES LIKE “general_log%”;

+——————+—————————-+
| Variable_name | Value |
+——————+—————————-+
| general_log | OFF |
| general_log_file | /var/run/mysqld/mysqld.log |
+——————+—————————-+

mysql> SET GLOBAL general_log = ‘ON’;

mysql> SET GLOBAL general_log = ‘OFF’;

http://stackoverflow.com/questions/568564/how-can-i-view-live-mysql-queries

c# convert int number to human readable word text date

public static class DateUtility
{
    private static string[] _unitsMap = new[]
    {
    "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten",
    "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"
    };

    private static string[] _tensMap = new[]
    {
    "Zero", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"
    };

    private static string[] _days = new string[]
    {
    "First", "Second", "Thrid", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", "Ninth", "Tenth",
    "Eleventh", "Twelfth", "Thirteenth", "Fourteenth", "Fifteenth", "Sixtenth", "Seventeenth",
    "Eighteenth", "Nineteenth", "Twentieth", "Twenty-First", "Twenty-Second", "Twenty-Third",
    "Twenty-Fourth", "Twenty-Fifth", "Twenty-Sixth", "Twenty-Seventh", "Twenty-Eighth",
    "Twenty-Ninth", "Thirtieth", "Thirty-First"
    };

    private static string[] _month = new string[]
    {
    "January", "February", "March", "April", "May", "June",
    "July", "August", "September", "October", "November", "December"
    };

    private static string[] _shortMonth = new string[]
    {
    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
    };

    private static string NumberToWords(int number)
    {
        if (number == 0)
            return "Zero";

        if (number < 0) return "Minus " + NumberToWords(Math.Abs(number)); string words = ""; if ((number / 1000000) > 0)
        {
            words += NumberToWords(number / 1000000) + " Million ";
            number %= 1000000;
        }

        if ((number / 1000) > 0)
        {
            words += NumberToWords(number / 1000) + " Thousand ";
            number %= 1000;
        }

        if ((number / 100) > 0)
        {
            words += NumberToWords(number / 100) + " Hundred ";
            number %= 100;
        }

        if (number > 0)
        {
            if (words != "")
                words += "and ";

            if (number < 20) words += _unitsMap[number];
            else
            {
                words += _tensMap[number / 10]; if ((number % 10) > 0)
                    words += "-" + _unitsMap[number % 10];
            }
        }

        return words;
    }

    public static string GetDayWord(int day)
    {
        day--;

        if (day < 0 || day >= _days.Length)
            return string.Empty;

        return _days[day];
    }

    public static string GetMonthWord(int month)
    {
        month--;

        if (month < 0 || month >= _month.Length)
            return string.Empty;

        return _month[month];
    }

    public static string GetShortMonthWord(int month)
    {
        month--;

        if (month < 0 || month >= _shortMonth.Length)
            return string.Empty;

        return _shortMonth[month];
    }

    public static string GetYearWord(int year)
    {
        if (year < 0 || year > 9999)
        {
            return string.Empty;
        }
        else
        {
            return NumberToWords(year);
        }
    }

    public static string GetWord(DateTime dateTime)
    {
        return GetWord(dateTime.Year, dateTime.Month, dateTime.Day);
    }

    public static string GetWord(int year, int month, int day)
    {
        string word = string.Empty;

        string dayWord = GetDayWord(day);
        string monthWord = GetMonthWord(month);
        string yearWord = GetYearWord(year);

        return string.Format(@"{0} of {1} {2}", dayWord, monthWord, yearWord);
    }
}