vidkid
|
2004-04-21 17:59:42, Á¶È¸ : 3,945, Ãßõ : 485 |
- Download #1 : http2.zip (2.1 KB), Download : 102

[À¥¼¹ö¿ÍÀÇ ¸¸³² #3] µ¥ÀÌÅ͸¦ RecordSet À¸·Î ¹Þ±â - ÇÁ·Î½ÃÀú ¸¸µé±â
¾È³çÇϼ¼¿ä. vidkid ÀÔ´Ï´Ù.
À̹ø¿¡´Â ¼¹ö·ÎºÎÅÍ Å×À̺í ÇüÅÂÀÇ µ¥ÀÌÅ͸¦ ¹Þ¾Æ¼ Ŭ¶óÀÌ¾ðÆ®¿¡ Ç¥½ÃÇØÁÖ´Â
°øºÎ¸¦ ÇØº¸ÁÒ..
(* ÇÁ·ÎÁ§Æ® ÆÄÀÏÀº ÷ºÎ ÆÄÀÏÀ» ÀÌ¿ëÇØ ÁÖ¼¼¿ä.)
ÀÌÀü °Á¿¡¼´Â ¼¹ö¿¡ÀÖ´Â php ¸¦ È£ÃâÇØ¼ µ¥ÀÌÅ͸¦ ¹Þ¾Æ ¿À´Â °Í±îÁö Çß½À´Ï´Ù.
¿Ü¿ï Çʿ䵵 ¾ø°í ÇÁ·Î½ÃÀú·Î ¸¸µé¾î¼ »ç¿ëÇÏ¸é Æí¸®ÇÏ°Ô »ç¿ëÇÏ°í ½±°Ô »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.
±×·¡¼ ¿ì¼±ÀûÀ¸·Î GET °ú POST ¸¦ Áö¿øÇÏ´Â ÇÁ·Î½ÃÀú µÎ°³¸¦ ¸¸µé¾ú½À´Ï´Ù.
httplib.scurl ÆÄÀÏÀ» IDE ·Î ¿¾îº¸½Ã¸é 2°³ÀÇ ÇÁ·Î½ÃÁ®°¡ ÀÖ½À´Ï´Ù.
Çϳª¾¿ ³»¿ëÀ» »ìÆìº¸°Ú½À´Ï´Ù.
(httplib.scurl ÀÇ gfGetMethod ÇÁ·Î½ÃÁ®)
-------------------------------------------------------------------------------------------
{define-proc public {gfGetMethod query-url : Url, charset : CharEncoding }:(String, bool)
let string-buf : StringBuf = {new StringBuf}
let num-read : int = 0
let error? : bool = false
let result : String = ""
{try
{with-file-caching-style FileCachingStyle.reload do
set (string-buf, num-read) = {read-from character-encoding = charset, query-url}
}
catch th:Throwable do
let str : String = th.value
{if {str.find-string "403"} >= 0 then
set string-buf = {StringBuf "403"}
set error? = true
elseif {str.find-string "404"} >= 0 then
set string-buf = {StringBuf "404"}
set error? = true
else
set string-buf = {StringBuf "100"}
set error? = true
}
}
set result = {string-buf.to-String}
{return result, error? }
}
-------------------------------------------------------------------------------------------
ÀÌÀü °Á¿¡¼ GET ¹æ½ÄÀ¸·Î µ¥ÀÌÅ͸¦ °¡Á®¿À±â À§ÇÑ ºÎºÐÀ» ÇÁ·Î½ÃÁ®·Î ¸¸µç ¼Ò½ºÀÔ´Ï´Ù.
´ëºÎºÐ Ä£¼÷ÇÑ ¼Ò½º¶ó »ý°¢µÇ³×¿ä.
À̹ø¿£
{try
...
catch th:Throwable do
...
}
ÀÇ catch ºÎºÐ¿¡ ¸¹Àº Äڵ尡 µé¾î°¬½À´Ï´Ù.
ÀÌ ³»¿ëÀº ¼¹ö·ÎºÎÅÍ html body ÀÇ ³»¿ë(th:Throwable ÀÇ ³»¿ë) ¿¡ 404, 403 ¿¡·¯°¡
³ª¿Â°æ¿ì¸¦ üũÇϱâ¿ìÇÑ ÄÚµåÀÔ´Ï´Ù.
º°·Î ÁÁÀº ¹æ¹ýÀº ¾Æ´ÏÁö¸¸ ´ëºÎºÐÀÇ °æ¿ì Àß µ¿ÀÛÇÕ´Ï´Ù.
404 ´Â ´ëºÎºÐ ¾Æ½Ã´Ù½ÃÇÇ ÇØ´ç url ¿¡ ÆÄÀÏÀÌ ¾ø´Â °æ¿ìÀ̰í,
403 Àº session À» »ç¿ëÇØ¼ ·Î±×ÀÎ °ü¸®¸¦ ÇÏ´Ù°¡ ¼¹ö°¡ restart µÈ°æ¿ì session ÀÌ ¾ø¾îÁö¸é¼
³ª¿À´Â ¿¡·¯ÀÔ´Ï´Ù.
ÀÌ ÇÁ·Î½ÃÁ®´Â 2°³ÀÇ °ªÀ» ¸®ÅÏÇÕ´Ï´Ù. ÀÌ°Ç ±×³É ÂüÁ¶Çϼ¼¿ä.
º°·Î ¾î·Á¿î ³»¿ëÀÌ ¾Æ´Ï´Ï±ñ ³Ñ¾î°¡°Ú½À´Ï´Ù.
(httplib.scurl ÀÇ gfGetMethod ÇÁ·Î½ÃÁ®)
-------------------------------------------------------------------------------------------
{define-proc public {gfPostMethod query-url : Url, charset : CharEncoding, ... }:(String, bool)
let error? : bool = false
let script-loc:Url = query-url
let http-file:HttpFile = {script-loc.instantiate-File} asa HttpFile
let req:HttpFormData = {HttpFormData
mime-type = HttpFormData.urlencoded-mime-type,
default-character-encoding=charset
}
{for param : HttpFormStringParam in ... do
{req.append param}
}
let web-stream:#HttpTextInputStream
{with-file-caching-style FileCachingStyle.reload do
set web-stream =
{http-file.http-read-open
character-encoding=charset,
request-data = req,
request-method = HttpRequestMethod.post
}
}
let returned : String = ""
let lines:{Array-of StringBuf} = {{Array-of StringBuf}}
let n-lines:int = 0
{try
||set gGlobalErrorCode = ""
set (lines, n-lines) = {web-stream.read-lines}
catch th:Throwable do
let str : String = th.value
{if {str.find-string "403"} >= 0 then
set returned = "403"
set error? = true
elseif {str.find-string "404"} >= 0 then
set returned = "404"
set error? = true
else
set returned = "100"
set error? = true
}
finally
{web-stream.close}
}
{if not error? then
{for i :int=0 below n-lines do
set returned = returned & "\n" & {lines[i].to-String}
}
}
{return returned, error?}
}
-------------------------------------------------------------------------------------------
À̹ø¿£ POST ¸Þ¼ÒµåÀÔ´Ï´Ù.
¿ª½Ã ÀÌÀü °Á¸¦ ÀÐÀ¸¼Ì´Ù¸é Ä£±ÙÇÑ ¼Ò½ºÀÔ´Ï´Ù.
Á» ƯÀÌÇÑ Á¡Àº
{define-proc public {gfPostMethod query-url : Url, charset : CharEncoding, ... }:(String, bool)
|| »ý·«
}
À§¿Í °°ÀÌ argument ·Î ... (rest arguments) ¸¦ ¹Þ¾Ò´Ù´Â °ÍÀÔ´Ï´Ù.
À̰ÍÀº gfPostMethod ¸¦ »ç¿ëÇÒ¶§ POST ¹æ½ÄÀ¸·Î ³Ñ°ÜÁú ÆÄ¶ó¸ÞÅ͸¦ Á÷Á¢ ¹Þ±âÀ§Çؼ »ç¿ëÇÑ °ÍÀÔ´Ï´Ù.
µÚ¿¡ ¹«¾ùÀÌ µé¾î¿À´øÁö ¹Þ°Ú´Ù´Â Àǹ̰ÚÁÒ..
¿©±â¼´Â HttpFormStringParam Ŭ·¡½º °´Ã¼ÀÇ ÆÄ¶ó¸ÞÅ͸¦ ¹Þ½À´Ï´Ù.
{for param : HttpFormStringParam in ... do
{req.append param}
}
¹Ù·Î ÀÌ ºÎºÐÀÌ ... ¾È¿¡¼ HttpFormStringParam ¸¦ ¹Þ¾Æ¼ req ¿¡ Ãß°¡ÇÏ´Â ºÎºÐÀÔ´Ï´Ù.
¸¸¾à ¿©·¯ºÐ²²¼ »ç¿ëÇϽŴٸé..
{gfPostMethod {url "test.php"}, {get-character-encoding-by-name "euc-kr"},
{HttpFormStringParam "mode", "list"},
{HttpFormStringParam "no", "7"}
}
À§¿Í °°ÀÌ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.
Âü Æí¸®ÇÕ´Ï´Ù. ^^;
³ª¸ÓÁö ¼Ò½º´Â ÀÌÀü°ú °°À¸´Ï »ý·«ÇϰڽÀ´Ï´Ù.
Çѹø ¾î¶»°Ô ¾²´ÂÁö ¿¹Á¦¸¦ È®ÀÎÇØ º¼±î¿ä..
(start1.curl)
-------------------------------------------------------------------------------------------
{curl 3.0 applet}
{curl-file-attributes character-encoding = "euc-kr"}
{applet manifest = "manifest.mcurl"}
{include "httplib.scurl"}
{value
{HBox
{CommandButton label="GET",
{on Action do
let (result :String, error? : bool) =
{gfGetMethod
{url "http://localhost/study/http2/start1.php?mode=list&no=7"},
{get-character-encoding-by-name "euc-kr"}
}
{popup-message result}
}
},
{CommandButton label="POST",
{on Action do
let (result :String, error? : bool) =
{gfPostMethod
{url "http://localhost/study/http2/start1.php"},
{get-character-encoding-by-name "euc-kr"},
{HttpFormStringParam "mode", "list"},
{HttpFormStringParam "no", "7"}
}
{popup-message result}
}
}
}
}
-------------------------------------------------------------------------------------------
¼Ò½º´Â CommandButton µÎ°³¸¦ »ç¿ëÇÕ´Ï´Ù. °¢°¢ GET °ú POST ÀÔ´Ï´Ù.

¼Ò½º¸¦ ³Ö¾ú´õ´Ï ±æ¾îÁ³³×¿ä..
ÀÌ °Á´ À̰ɷΠÇϰí..
´ÙÀ½ °Á¿¡¼ ºËÁÒ..^^
|
|
|