CGI
argcã§ãã©ã¡ã¼ã¿ã®æ°ãåå¾ã§ããã¨ãããã¨ã¯ãargvã§åã ã®ãã©ã¡ã¼ã¿ãåããããã©ã¡ã¼ã¿action.cã§ãããããã¨ã '+'ã§ç¹ãã å ´åã¯'+'ã§ç¹ãã å ´åã¯ã åã ã®ãã©ã¡ã¼ã¿ãåå¾ã§ããåã ã®ãã©ã¡ã¼ã¿ãåå¾ã§ããã ä¸çªæåã®è¦ç´ ã¯ãCGIã¾ã§ã®ãâ¦
Cè¨èªCGIã®å ´åãmainé¢æ°ã®argcã¯ã"GETã®ã¯ã¨ãªãã©ã¡ã¼ã¿ã®æ°" + 1ãå ¥ã£ã¦ããããã©ã¡ã¼ã¿ä¸è¨ãªã³ã¯ã¯Perlã ãã©ãCè¨èªã§ãåãã ãã ããargcããã¡ãã¨åå¾ã§ããã¯ã¨ãªã«ã¯æ¡ä»¶ãããã argc.htmlã§ã <html> <head> <title>argc</title> </head> <body> <script type="text/javascript"> <!-- // --> </script> <form method="GET" action="/cgi-bin/action.cgi"> <input value="value1"> </form></body></html>
èªã¿è¾¼ã¿ããã¤ããªãã¡ã¤ã«ã«å¯¾å¿ããã®ã§ããããããããã¡ã¤ã«ãã¢ãããã¼ãåºæ¥ãããã«ãããhttps://wa3.i-3-i.info/word15799.htmlaction.cã§ãã¬ã¹ãã³ã¹ãããã®Content-typeã§file_content_typeãåºåããããã«ãã¦ããã®ã§ããã¤ããªã§ããªãâ¦
ããã¹ããã¡ã¤ã«ã®å ´åã¯ãHTTPãªã¯ã¨ã¹ãããã£ãNULLæåã§åããäºãç¡ãã®ã§ãboundaryãstrstrã§æ¢ãã¦ãããããã¤ããªãã¡ã¤ã«ã ã¨ããã¯ãããªããhttps://www.ietf.org/rfc/rfc1867.txtmemcmpã¨foræã§ãæ¢ç´¢ãã¦ãã ä»åã®HTTPã¬ã¹ãã³ã¹ããã£â¦
multipart/form-dataã®å ´åã¯ãã©ããã£ã¦ãã¡ã¤ã«ãæ½åºãããã¨ããã®ã課é¡ã¨ãªããPOST - HTTP | MDNContent-type.htmlã¯ãããã¾ã§éããenctype="multipart/form-data"ã action.cã¯ã"CONTENT_TYPE"ã"multipart/form-data"ãã©ãããã§ãã¯ã ãã®å¾â¦
getenvã«"CONTENT_LENGTH"ãæå®ããã¨ãHTTPã®Bodyã®ãµã¤ãºãåå¾ã§ãããenqlÃóMaction.cã§ãgetenvã«"CONTENT_LENGTH"ãæå®ããã¨ãããã£ãµã¤ãºã"æååã§"è¿ã£ã¦ããã CONTENT_LENGTH.htmlã¯ããã¾ãå¤ãããªãã ãã¡ã¤ã«ãé¸æãã¦submitããã¨ãâ¦
getenvã«"CONTENT_TYPE"ãæå®ããã¨ã"Content-type"ãåå¾ã§ãããc++ã§cgi ã¼ ãã¡ã¤ã«ã®ã¢ãããã¼ã ~ ããã°ã©ã ã®ã¡ã¢action.cã§ãgetenvã«"CONTENT_TYPE"ãæå®ããè¿ã£ã¦ããæååãåºåã CONTENT_TYPE.htmlã¯ããã¡ã¤ã«ã ãéãã ãã¡ã¤ã«ãé¸â¦
ä¸è¬ã®ç°å¢å¤æ°ã¨ã¯å¥ã«ãCGIã®ç°å¢å¤æ°ãgetenvã§åå¾ãããã¨ãåºæ¥ãã6.1 QUERY_STRING CGIã®ä»æ§ - ã¨ã»ã»ã®WWWå ¥égetenvã«QUERY_STRINGãæå®ãã¦ã¿ããã¨ãã¦ã ãã®ã¾ã¾å¼ã³åºãã ã¨ããã®ã¾ã¾å¼ã³åºãã ã¨ã ä½ã表示ãããªãããã«è¦ãããä½ã表â¦
HTTPã®ã¹ãã¼ã¿ã¹ã³ã¼ãã¯Statusãããã§è¿ããCGIã®ä»æ§ - ã¨ã»ã»ã®WWWå ¥é CGI ããã°ã©ã ã®æ¹è¯æ¡/ãããã®æ¸ãæ¹ããã ãã¯HTTPã®ãããã§ã¯ãªããCGIå°ç¨ãããã status.cã§ã /* ããããã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã */ #include <stdio.h> /* æ¨æºå ¥åºå */ /* main</stdio.h>â¦
CGIã§ãªãã¤ã¬ã¯ããããå ´åã¯ãLocationããããåºåããã ããLocationãããã使ã£ã¦ã¸ã£ã³ããã | beginners CGIlocation.cã§ãã¨ããã ããå ¥åããã¨ããå ¥åããã¨ã ãã£ã¡ã«ãªãã¤ã¬ã¯ããã£ã¡ã«ãªãã¤ã¬ã¯ãã èªåã§302ã«ãªããã ãªãã»ã»ã»ãâ¦
"Content-type: text/plain"ã«ããã¨ããã¬ã¼ã³ããã¹ãã§è§£éããããMIME ã¿ã¤ã (IANA ã¡ãã£ã¢ã¿ã¤ã) - HTTP | MDNcontent_type.cããã«ããã¨ã 確ãã«HTMLã¨ãã¦ã¯è§£éãããããã¬ã¼ã³ããã¹ãã¨ãã¦è§£éããããSample/cgi/Content-type/text_plainâ¦
"Content-type: text/html"ã«ãã¦ããã°ãHTMLã¨ãã¦è§£éããããMIME ã¿ã¤ã (IANA ã¡ãã£ã¢ã¿ã¤ã) - HTTP | MDNcontent_type.cããã¨ããã¨ã HTMLã®ãªã³ã¯ã«ãªã£ã¦ãHTMLã®ãªã³ã¯ã«ãªã£ã¦ãã ãªã³ã¯ã¯ãªãã¯ã§ããã«é£ã¶ããªã³ã¯ã¯ãªãã¯ã§ããã«é£ã¶ãâ¦
ããããã¯ãCGIã«ã¤ãã¦æ±ã£ã¦ããã HTTPãããã®"Content-Type"ãä»ããã«ã¯ãCGIããã°ã©ã ã«ããããæ¸ããªãã¨ãããªãã (大æåå°æåãåºå¥ããªãã®ã§ã"Content-Type"ã§ã"Content-type"ã§ããããã©ã"Content-type"ã¨æ¸ã人ãå¤ããªãã»ã»ã»ã)Câ¦