Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HTTP və CGI

NEATS LLC
September 09, 2012

HTTP və CGI

Barama İnnovasiya Mərkəzi və Baku Google Developers Group tərəfindən mobil proqramçıların təcrübə mübadiləsinə yönəlik "Baku TechTalks" layihəsinin 9 sentyabr 2013-cü ildə keçirdiyi tədbirdə NEATS şirkətinin əməkdaşı Adil Əliyevin prezentasiyası.

NEATS LLC

September 09, 2012
Tweet

More Decks by NEATS LLC

Other Decks in Programming

Transcript

  1. GET GET / HTTP/1.1 Connection: Keep­Alive User­Agent: Mozilla/5.0 (X11; Linux

    x86_64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1 Accept: text/*, image/jpeg, image/png, image/*, */* Accept­Encoding: x­gzip, gzip, identity Accept­Charset: Any, utf­8, * Accept­Language: en, en_US Host: www.google.com
  2. GET HTTP/1.1 200 OK Date: Thu, 24 Jan 2002 17:33:52

    GMT Server: Apache/1.3.14 Last­Modified: Mon, 21 Jan 2002 22:08:33 GMT Etag: “47bc6­25e0­3c4c9161” Accept­Ranges: bytes Content­Length: 9696 Connection: close Content­Type: text/html ­­ blank line­­ ­­ HTML entity ­­
  3. CGI ... HTTP_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0 .9,*/*;q=0.8" HTTP_ACCEPT_CHARSET="ISO­8859­1,utf­8;q=0.7,*;q=0.7" HTTP_ACCEPT_ENCODING="gzip, deflate" HTTP_ACCEPT_LANGUAGE="en­us,en;q=0.5" HTTP_CONNECTION="keep­alive" HTTP_HOST="example.com"

    HTTP_USER_AGENT="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0" ... QUERY_STRING="var1=value1&var2=with%20percent%20encoding" REMOTE_ADDR="127.0.0.1" REMOTE_PORT="63555" REQUEST_METHOD="GET" REQUEST_URI="/toplama.cgi?m=4&n=2" ... http://example.com/toplama.cgi?m=4&n=2
  4. CGI #include <stdio.h> #include <stdlib.h> int main(void) { char *data;

    long m,n; printf("%s%c%c\n", "Content­Type:text/html;charset=utf­ 8",13,10); printf("<p>Toplama</p>\n"); data = getenv("QUERY_STRING"); sscanf(data,"m=%ld&n=%ld",&m,&n); printf("<p> %ld + %ld = %ld.",m,n,m*n); return 0; } http://example.com/toplama.cgi?m=4&n=2
  5. CGI və POST uses dos; var a:string; c:char; begin writeln('Content­Type:text/html',#10#13);

    a:=''; while not eof(input) do begin read(c); a:= a+c; end; writeln('POST: ',a); end.