|
MID ÇÁ·ÎÇÊ | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ÀÌ ÀÎÅÍÆäÀ̽º´Â HTTP ¿¬°á¿¡ ÇÊ¿äÇÑ ¸Þ¼Òµå¿Í »ó¼ö¸¦ Á¤ÀÇÇÕ´Ï´Ù.
HTTP´Â ¿äûÀ» º¸³»±â Àü¿¡ ¿äû ¸Å°³ º¯¼ö¸¦ ¼³Á¤ÇØ¾ß ÇÏ´Â ¿äû-ÀÀ´ä ÇÁ·ÎÅäÄÝÀÔ´Ï´Ù. ¿¬°á »óÅ´ ´ÙÀ½ ¼¼ °¡Áö Áß ÇϳªÀÔ´Ï´Ù.
setRequestMethod
setRequestProperty
¿¬°áÀÌ ¼³Á¤ »óÅÂÀÏ ¶§ ´ÙÀ½ ¸Þ¼Òµå¸¦ »ç¿ëÇÏ¸é ¿¬°áµÊ »óÅ·ΠÀüȯµË´Ï´Ù.
openInputStream
openDataInputStream
getLength
getType
getEncoding
getHeaderField
getResponseCode
getResponseMessage
getHeaderFieldInt
getHeaderFieldDate
getExpiration
getDate
getLastModified
getHeaderField
getHeaderFieldKey
´ÙÀ½ ¸Þ¼Òµå´Â ¿¬°áÀÌ ¼³Á¤ ¶Ç´Â ¿¬°áµÊ »óÅÂÀÏ ¶§¸¸ È£ÃâÇÒ ¼ö ÀÖ½À´Ï´Ù.
close
getRequestMethod
getRequestProperty
getURL
getProtocol
getHost
getFile
getRef
getPort
getQuery
openOutputStream
¶Ç´Â
openDataOutputStream
¸Þ¼Òµå°¡ Ãâ·Â ½ºÆ®¸²À» ¿¬ ÈÄ
setRequestMethod
¶Ç´Â setRequestProperty
¸¦
ÅëÇØ ¿äû ¸Å°³ º¯¼ö¸¦ º¯°æÇÏ·Á´Â ½Ãµµ´Â ¹«½ÃµË´Ï´Ù.
¿äû ¸Å°³ º¯¼ö¸¦ º¸³½ °æ¿ì ÀÌµé ¸Þ¼Òµå´Â IOException
À»
¹ß»ý½Ãŵ´Ï´Ù.
OutputStream.close
¶Ç´Â
DataOutputStream.close
¸Þ¼Òµå¸¦ ÅëÇØ Ãâ·Â ½ºÆ®¸²À» ´ÝÀ¸¸é
¿¬°á »óÅ´ ¿¬°áµÊÀÌ µË´Ï´Ù.
OutputStream.flush
¶Ç´Â
DataOutputStream.flush
¸Þ¼Òµå¸¦ ÅëÇØ Ãâ·Â ½ºÆ®¸²À»
Ç÷¯½ÃÇÒ °æ¿ì ½ºÆ®¸²¿¡ ±â·ÏµÇ´Â ¸ðµç µ¥ÀÌÅÍ¿Í ÇÔ²²
¿äû ¸Å°³ º¯¼ö¸¦ º¸³»¾ß ÇÕ´Ï´Ù.
close
¸Þ¼Òµå¸¦ »ç¿ëÇÏ¿© ¿¬°á¿¡¼ ¿¸°
¸ðµç ½ºÆ®¸²À» ´ÝÀ¸¸é ´Ù¸¥ µÎ »óÅ¿¡¼
´ÝÈû »óÅ·ΠÀüȯµË´Ï´Ù.
StreamConnection »ç¿ë ¿¹
StreamConnection
À» »ç¿ëÇÏ¿©
´Ü¼øÈ÷ URLÀ» Àб⸸ Çϸç HTTP °íÀ¯ÀÇ µ¿ÀÛÀº ÇÊ¿ä ¾ø°Å³ª »ç¿ëµÇÁö ¾Ê½À´Ï´Ù.
(ÁÖ: ÀÌ ¿¹¿¡¼´Â
¸ðµç HTTP ÀÀ´ä Çì´õ¿Í HTTP ÀÀ´ä Äڵ带
¹«½ÃÇÕ´Ï´Ù. ÇÁ·Ï½Ã³ª ¼¹ö°¡ ¿À·ù ÀÀ´ä ÆäÀÌÁö¸¦ º¸³ÂÀ» ¼öµµ ÀÖÀ¸¹Ç·Î
ÀÀ¿ë ÇÁ·Î±×·¥Àº InputStream
¿¡¼ ¾î¶² µ¥ÀÌÅͰ¡ °Ë»öµÇ´ÂÁö
±¸ºÐÇÒ ¼ö ¾ø½À´Ï´Ù.
Connector.open
À» »ç¿ëÇÏ¿© URLÀ» ¿°í
StreamConnection
ÀÌ ¹ÝȯµË´Ï´Ù.
StreamConnection
¿¡¼
InputStream
ÀÌ ¿¸³´Ï´Ù.
EOF(-1)±îÁö ¸ðµç ¹®ÀÚ¸¦ Àд µ¥ »ç¿ëµË´Ï´Ù.
¿¹¿Ü°¡ ¹ß»ýÇÏ¸é ¿¬°á°ú ½ºÆ®¸²ÀÌ ´ÝÈü´Ï´Ù.
void getViaStreamConnection(String url) throws IOException { StreamConnection c = null; InputStream s = null; try { c = (StreamConnection)Connector.open(url); s = c.openInputStream(); int ch; while ((ch = s.read()) != -1) { ... } } finally { if (s != null) s.close(); if (c != null) c.close(); } }
ContentConnection »ç¿ë ¿¹
ContentConnection
À» »ç¿ëÇÏ¿© ´Ü¼øÈ÷ URLÀ» Àб⸸ Çϸç
HTTP °íÀ¯ÀÇ µ¿ÀÛÀº ÇÊ¿ä ¾ø°Å³ª »ç¿ëµÇÁö ¾Ê½À´Ï´Ù.
Connector.open
À» »ç¿ëÇÏ¿© URLÀ» ¿°í
ContentConnection
ÀÌ ¹ÝȯµË´Ï´Ù.
ContentConnection
Àº ±æÀ̸¦ Á¦°øÇÒ ¼öµµ ÀÖ½À´Ï´Ù.
±æÀ̸¦ »ç¿ëÇÒ ¼ö ÀÖÀ¸¸é ±æÀ̸¦ »ç¿ëÇÏ¿© ´ë·®À¸·Î µ¥ÀÌÅ͸¦ ÀнÀ´Ï´Ù.
ContentConnection
¿¡¼
InputStream
ÀÌ ¿¸³´Ï´Ù.
EOF(-1)±îÁö ¸ðµç ¹®ÀÚ¸¦ Àд µ¥ »ç¿ëµË´Ï´Ù.
¿¹¿Ü°¡ ¹ß»ýÇÏ¸é ¿¬°á°ú ½ºÆ®¸²ÀÌ ´ÝÈü´Ï´Ù.
void getViaContentConnection(String url) throws IOException { ContentConnection c = null; DataInputStream is = null; try { c = (ContentConnection)Connector.open(url); int len = (int)c.getLength(); dis = c.openDataInputStream(); if (len > 0) { byte[] data = new byte[len]; dis.readFully(data); } else { int ch; while ((ch = dis.read()) != -1) { ... } } } finally { if (dis != null) dis.close(); if (c != null) c.close(); } }
HttpConnection »ç¿ë ¿¹
HttpConnection
À» »ç¿ëÇÏ¿© HTTP Çì´õ¿Í µ¥ÀÌÅ͸¦ ÀнÀ´Ï´Ù.
Connector.open
À» »ç¿ëÇÏ¿© URLÀ» ¿°í
HttpConnection
ÀÌ ¹ÝȯµË´Ï´Ù.
HTTP Çì´õ¸¦ Àаí ó¸®ÇÕ´Ï´Ù.
±æÀ̸¦ »ç¿ëÇÒ ¼ö ÀÖÀ¸¸é ±æÀ̸¦ »ç¿ëÇÏ¿© ´ë·®À¸·Î µ¥ÀÌÅ͸¦ ÀнÀ´Ï´Ù.
HttpConnection
¿¡¼
InputStream
ÀÌ ¿¸³´Ï´Ù.
EOF(-1)±îÁö ¸ðµç ¹®ÀÚ¸¦ Àд µ¥ »ç¿ëµË´Ï´Ù.
¿¹¿Ü°¡ ¹ß»ýÇÏ¸é ¿¬°á°ú ½ºÆ®¸²ÀÌ ´ÝÈü´Ï´Ù.
void getViaHttpConnection(String url) throws IOException { HttpConnection c = null; InputStream is = null; int rc; try { c = (HttpConnection)Connector.open(url); // Getting the response code will open the connection, // send the request, and read the HTTP response headers. // The headers are stored until requested. rc = c.getResponseCode(); if (rc != HttpConnection.HTTP_OK) { throw new IOException("HTTP response code: " + rc); } is = c.openInputStream(); // Get the ContentType String type = c.getType(); // Get the length and process the data int len = (int)c.getLength(); if (len > 0) { int actual = 0; int bytesread = 0 ; byte[] data = new byte[len]; while ((bytesread != len) && (actual != -1)) { actual = is.read(data, bytesread, len - bytesread); bytesread += actual; } } else { int ch; while ((ch = is.read()) != -1) { ... } } } catch (ClassCastException e) { throw new IllegalArgumentException("Not an HTTP URL"); } finally { if (is != null) is.close(); if (c != null) c.close(); } }
POST ¹× HttpConnection »ç¿ë ¿¹
ÀϺΠÇì´õ¿Í ³»¿ëÀÌ Æ÷ÇÔµÈ ¿äûÀ» ¼¹ö¿¡ °Ô½ÃÇϰí Çì´õ¿Í ³»¿ëÀ» ó¸®ÇÕ´Ï´Ù.
Connector.open
À» »ç¿ëÇÏ¿© URLÀ» ¿°í
HttpConnection
ÀÌ ¹ÝȯµË´Ï´Ù.
¿äû ¸Þ¼Òµå´Â POST¿Í ¿äû Çì´õ ÁýÇÕÀ¸·Î ¼³Á¤µË´Ï´Ù.
´Ü¼øÇÑ ¸í·ÉÀ» ÀÛ¼ºÇϰí Ç÷¯½ÃÇÕ´Ï´Ù.
HTTP Çì´õ¸¦ Àаí ó¸®ÇÕ´Ï´Ù.
±æÀ̸¦ »ç¿ëÇÒ ¼ö ÀÖÀ¸¸é ±æÀ̸¦ »ç¿ëÇÏ¿© ´ë·®À¸·Î µ¥ÀÌÅ͸¦ ÀнÀ´Ï´Ù.
HttpConnection
¿¡¼
InputStream
ÀÌ ¿¸³´Ï´Ù.
EOF(-1)±îÁö ¸ðµç ¹®ÀÚ¸¦ Àд µ¥ »ç¿ëµË´Ï´Ù.
¿¹¿Ü°¡ ¹ß»ýÇÏ¸é ¿¬°á°ú ½ºÆ®¸²ÀÌ ´ÝÈü´Ï´Ù.
void postViaHttpConnection(String url) throws IOException { HttpConnection c = null; InputStream is = null; OutputStream os = null; int rc; try { c = (HttpConnection)Connector.open(url); // Set the request method and headers c.setRequestMethod(HttpConnection.POST); c.setRequestProperty("If-Modified-Since", "29 Oct 1999 19:43:31 GMT"); c.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0"); c.setRequestProperty("Content-Language", "en-US"); // Getting the output stream may flush the headers os = c.openOutputStream(); os.write("LIST games\n".getBytes()); os.flush(); // Optional, getResponseCode will flush // Getting the response code will open the connection, // send the request, and read the HTTP response headers. // The headers are stored until requested. rc = c.getResponseCode(); if (rc != HttpConnection.HTTP_OK) { throw new IOException("HTTP response code: " + rc); } is = c.openInputStream(); // Get the ContentType String type = c.getType(); processType(type); // Get the length and process the data int len = (int)c.getLength(); if (len > 0) { int actual = 0; int bytesread = 0 ; byte[] data = new byte[len]; while ((bytesread != len) && (actual != -1)) { actual = is.read(data, bytesread, len - bytesread); bytesread += actual; } process(data); } else { int ch; while ((ch = is.read()) != -1) { process((byte)ch); } } } catch (ClassCastException e) { throw new IllegalArgumentException("Not an HTTP URL"); } finally { if (is != null) is.close(); if (os != null) os.close(); if (c != null) c.close(); } }
Ä¿³ØÅÍ¿¡ ´ëÇÑ ´Ü¼øÇÑ ½ºÆ®¸² ¸Þ¼Òµå
ÁÖÀÇ: Connector
Ŭ·¡½º´Â
ÁöÁ¤µÈ URL¿¡ ´ëÇÑ
ÀÔ·Â ¶Ç´Â Ãâ·Â ½ºÆ®¸²À» Á÷Á¢ °Ë»öÇϱâ À§ÇÑ
´ÙÀ½°ú °°Àº Æí¸®ÇÑ ¸Þ¼Òµå¸¦ Á¤ÀÇÇÕ´Ï´Ù.
InputStream openInputStream(String url)
DataInputStream openDataInputStream(String url)
OutputStream openOutputStream(String url)
DataOutputStream openDataOutputStream(String url)
getRequestMethod()
setRequestMethod()
getRequestProperty()
setRequestProperty()
getLength()
getType()
getEncoding()
getHeaderField()
getResponseCode()
getResponseMessage()
getHeaderFieldInt
getHeaderFieldDate
getExpiration
getDate
getLastModified
getHeaderField
getHeaderFieldKey
Field Summary | |
static String |
GET
HTTP Get ¸Þ¼Òµå |
static String |
HEAD
HTTP Head ¸Þ¼Òµå |
static int |
HTTP_ACCEPTED
202: ¿äû 󸮰¡ ½ÂÀεǾúÁö¸¸ 󸮰¡ ¿Ï·áµÇÁö ¾Ê¾Ò½À´Ï´Ù. |
static int |
HTTP_BAD_GATEWAY
502: °ÔÀÌÆ®¿þÀ̳ª ÇÁ·Ï½Ã·Î ÀÛµ¿ÇÏ´Â ¼¹ö°¡ ¿äû ÀÌÇà Áß¿¡ ¾×¼¼½ºÇÑ ¾÷½ºÆ®¸² ¼¹ö·ÎºÎÅÍ À¯È¿ÇÏÁö ¾ÊÀº ÀÀ´äÀ» ¹Þ¾Ò½À´Ï´Ù. |
static int |
HTTP_BAD_METHOD
405: Request-Line¿¡ ÁöÁ¤µÈ ¸Þ¼Òµå¸¦ Request-URI·Î ½Äº°µÈ ÀÚ¿ø¿¡ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù. |
static int |
HTTP_BAD_REQUEST
400: À߸øµÈ Çü½ÄÀÇ ±¸¹® ¶§¹®¿¡ ¼¹ö¿¡¼ ¿äûÀ» ÀÌÇØÇÒ ¼ö ¾ø½À´Ï´Ù. |
static int |
HTTP_CLIENT_TIMEOUT
408: Ŭ¶óÀÌ¾ðÆ®°¡ ¼¹ö ´ë±â ½Ã°£ ³»¿¡ ¿äûÇÏÁö ¸øÇß½À´Ï´Ù. |
static int |
HTTP_CONFLICT
409: ¿äûÀÌ ÀÚ¿øÀÇ ÇöÀç »óÅÂ¿Í Ãæµ¹ÇϹǷΠ¿äûÀ» ¿Ï·áÇÒ ¼ö ¾ø½À´Ï´Ù. |
static int |
HTTP_CREATED
201: ¿äûÀÌ ÀÌÇàµÇ¾úÀ¸¸ç ±× °á°ú »õ·Î¿î ÀÚ¿øÀÌ ¸¸µé¾îÁ³½À´Ï´Ù. |
static int |
HTTP_ENTITY_TOO_LARGE
413: ¼¹ö¿¡¼ ó¸®ÇÒ ¼ö ÀÖ´Â °Íº¸´Ù ¿äû ¿£Æ¼Æ¼°¡ ´õ Å©¹Ç·Î ¼¹ö°¡ ¿äû 󸮸¦ °ÅºÎÇÕ´Ï´Ù. |
static int |
HTTP_EXPECT_FAILED
417: ¼¹ö°¡ Expect ¿äû Çì´õ Çʵ忡 ÁöÁ¤µÈ ±â´ë¸¦ ÃæÁ·½Ãų ¼ö ¾ø°Å³ª, ¼¹ö°¡ ÇÁ·Ï½ÃÀÎ °æ¿ì ´ÙÀ½ °æÀ¯ ¼¹ö¿¡¼ ¿äûÀ» ÃæÁ·½Ãų ¼ö ¾ø´Ù´Â È®½ÇÇÑ Áõ°Å°¡ ÀÖ½À´Ï´Ù. |
static int |
HTTP_FORBIDDEN
403: ¼¹ö°¡ ¿äûÀ» ÀÌÇØÇßÁö¸¸ ÀÌÇàÇϱ⸦ °ÅºÎÇÕ´Ï´Ù. |
static int |
HTTP_GATEWAY_TIMEOUT
504: °ÔÀÌÆ®¿þÀ̳ª ÇÁ·Ï½Ã·Î ÀÛµ¿ÇÏ´Â ¼¹ö°¡ ¿äû ¿Ï·á Áß¿¡ ¾×¼¼½ºÇÑ URI ¶Ç´Â ´Ù¸¥ º¸Á¶ ¼¹ö¿¡ ÀÇÇØ ÁöÁ¤µÈ ¾÷½ºÆ®¸² ¼¹ö·ÎºÎÅÍ ÀûÀýÇÑ ÀÀ´äÀ» ¹ÞÁö ¸øÇß½À´Ï´Ù. |
static int |
HTTP_GONE
410: ¿äûµÈ ÀÚ¿øÀº ¼¹ö¿¡¼ ´õ ÀÌ»ó »ç¿ëÇÒ ¼ö ¾øÀ¸¸ç Àü´Þ ÁÖ¼Ò¸¦ ¾Ë ¼ö ¾ø½À´Ï´Ù. |
static int |
HTTP_INTERNAL_ERROR
500: ¼¹ö¿¡¼ ¿¹»óÄ¡ ¸øÇÑ Á¶°ÇÀ» ¹ß°ßÇÏ¿© ¿äûÀ» ÀÌÇàÇÏÁö ¸øÇß½À´Ï´Ù. |
static int |
HTTP_LENGTH_REQUIRED
411: ¼¹ö¿¡¼ Content- Length°¡ Á¤ÀǵÇÁö ¾ÊÀº ¿äûÀ» °ÅºÎÇÕ´Ï´Ù. |
static int |
HTTP_MOVED_PERM
301: ¿äûµÈ ÀÚ¿ø¿¡ »õ·Î¿î ¿µ±¸ URLÀÌ ÇÒ´çµÇ¾úÀ¸¸ç ÀÌ ÀÚ¿ø¿¡ ´ëÇÑ ÀÌÈÄ ÂüÁ¶´Â ¹ÝȯµÈ URI Áß Çϳª¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ÁÁ½À´Ï´Ù. |
static int |
HTTP_MOVED_TEMP
302: ¿äûµÈ ÀÚ¿øÀÌ ÀϽÃÀûÀ¸·Î ´Ù¸¥ URI¿¡ ÀÖ½À´Ï´Ù. |
static int |
HTTP_MULT_CHOICE
300: ¿äûµÈ ÀÚ¿øÀÌ °¢°¢ ƯÁ¤ À§Ä¡¸¦ °¡Áø Ç¥Çö ÁýÇÕ Áß Çϳª¿¡ ÀÏÄ¡Çϸç, »ç¿ëÀÚ°¡ ¿øÇϴ ǥÇöÀ» ¼±ÅÃÇÏ°í ¿äûÀ» ÇØ´ç À§Ä¡·Î ¸®µð·º¼ÇÇÒ ¼ö ÀÖµµ·Ï ¿¡ÀÌÀüÆ® ±¸µ¿ Çù»ó Á¤º¸°¡ Á¦°øµË´Ï´Ù. |
static int |
HTTP_NO_CONTENT
204: ¼¹ö¿¡¼ ¿äûÀ» ÀÌÇàÇßÁö¸¸ entity-body¸¦ ¹ÝȯÇÒ Çʿ䰡 ¾øÀ¸¸ç ¾÷µ¥ÀÌÆ®µÈ meta-informationÀ» ¹ÝȯÇÒ ¼öµµ ÀÖ½À´Ï´Ù. |
static int |
HTTP_NOT_ACCEPTABLE
406: ¿äû¿¡ ÀÇÇØ ½Äº°µÈ ÀÚ¿øÀÌ ¿äû ½Ã Àü¼ÛµÈ ½ÂÀÎ Çì´õ¿¡ µû¶ó ½ÂÀÎÇÒ ¼ö ¾ø´Â ³»¿ëÀÌ Æ÷ÇÔµÈ ÀÀ´ä ¿£Æ¼Æ¼¸¸ »ý¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù. |
static int |
HTTP_NOT_AUTHORITATIVE
203: entity-header¿¡ ¹ÝȯµÈ meta-informationÀº ¿øº» ¼¹ö¿¡¼ »ç¿ëÇÒ ¼ö ÀÖ´Â Á¤ÀÇ ÁýÇÕÀÌ ¾Æ´Õ´Ï´Ù. |
static int |
HTTP_NOT_FOUND
404: ¼¹ö¿¡¼ Request-URI¿¡ ÀÏÄ¡ÇÏ´Â Ç׸ñÀ» ãÁö ¸øÇß½À´Ï´Ù. |
static int |
HTTP_NOT_IMPLEMENTED
501: ¼¹ö¿¡¼ ¿äû ÀÌÇà¿¡ ÇÊ¿äÇÑ ±â´ÉÀ» Áö¿øÇÏÁö ¾Ê½À´Ï´Ù. |
static int |
HTTP_NOT_MODIFIED
304: Ŭ¶óÀÌ¾ðÆ®°¡ Á¶°ÇºÎ GET ¿äûÀ» ¼öÇàÇßÀ¸¸ç ¾×¼¼½º°¡ Çã¿ëµÇ¾úÁö¸¸ ¹®¼¸¦ ¼öÁ¤ÇÏÁö ¾ÊÀº °æ¿ì ¼¹ö´Â ÀÌ »óÅ ÄÚµå·Î ÀÀ´äÇÏ´Â °ÍÀÌ ÁÁ½À´Ï´Ù. |
static int |
HTTP_OK
200: ¿äûÀÌ ¼º°øÇß½À´Ï´Ù. |
static int |
HTTP_PARTIAL
206: ¼¹ö¿¡¼ ÀÚ¿ø¿¡ ´ëÇÑ ºÎºÐ GET ¿äûÀ» ÀÌÇàÇß½À´Ï´Ù. |
static int |
HTTP_PAYMENT_REQUIRED
402: ÀÌ ÄÚµå´Â ÀÌÈÄ »ç¿ëÀ» À§ÇØ ¿¹¾àµË´Ï´Ù. |
static int |
HTTP_PRECON_FAILED
412: Çϳª ÀÌ»óÀÇ ¿äû Çì´õ Çʵ忡 ÁöÁ¤µÈ »çÀü Á¶°ÇÀ» ¼¹ö¿¡¼ Å×½ºÆ®ÇÑ °á°ú false·Î Æò°¡µÇ¾ú½À´Ï´Ù. |
static int |
HTTP_PROXY_AUTH
407: ÀÌ ÄÚµå´Â 401 (Unauthorized)¿Í À¯»çÇÏÁö¸¸ Ŭ¶óÀÌ¾ðÆ®°¡ ¸ÕÀú ÇÁ·Ï½Ã¸¦ »ç¿ëÇÏ¿© ÀÚ½ÅÀ» ÀÎÁõÇØ¾ß ÇÔÀ» ³ªÅ¸³À´Ï´Ù. |
static int |
HTTP_REQ_TOO_LONG
414: Request-URI°¡ ¼¹ö¿¡¼ ÇØ¼®ÇÒ ¼ö ÀÖ´Â °Íº¸´Ù ±æ¾î¼ ¼¹ö°¡ ¿äû 󸮸¦ °ÅºÎÇÕ´Ï´Ù. |
static int |
HTTP_RESET
205: ¼¹ö¿¡¼ ¿äûÀ» ÀÌÇàÇßÀ¸¸ç »ç¿ëÀÚ ¿¡ÀÌÀüÆ®´Â ¿äûÀ» º¸³»°Ô ÇÑ ¹®¼ º¸±â¸¦ Àç¼³Á¤ÇÏ´Â °ÍÀÌ ÁÁ½À´Ï´Ù. |
static int |
HTTP_SEE_OTHER
303: ¿äû¿¡ ´ëÇÑ ÀÀ´äÀº ´Ù¸¥ URI¿¡¼ ãÀ» ¼ö ÀÖÀ¸¸ç ÇØ´ç ÀÚ¿ø¿¡ ´ëÇÑ GET ¸Þ¼Òµå¸¦ »ç¿ëÇÏ¿© °Ë»öÇÏ´Â °ÍÀÌ ÁÁ½À´Ï´Ù. |
static int |
HTTP_TEMP_REDIRECT
307: ¿äûµÈ ÀÚ¿øÀÌ ÀϽÃÀûÀ¸·Î ´Ù¸¥ URI¿¡ ÀÖ½À´Ï´Ù. |
static int |
HTTP_UNAUTHORIZED
401: ¿äû¿¡ »ç¿ëÀÚ ÀÎÁõÀÌ ÇÊ¿äÇÕ´Ï´Ù. |
static int |
HTTP_UNAVAILABLE
503: ÀϽÃÀû ¿À¹ö·Îµå ¶Ç´Â À¯Áö º¸¼ö·Î ÀÎÇØ ÇöÀç ¼¹ö¿¡¼ ¿äûÀ» ó¸®ÇÒ ¼ö ¾ø½À´Ï´Ù. |
static int |
HTTP_UNSUPPORTED_RANGE
416: ¿äû¿¡ Range ¿äû Çì´õ Çʵ尡 Æ÷ÇԵǾî ÀÖÁö¸¸ ÀÌ ÇʵåÀÇ ¹üÀ§ ÁöÁ¤ÀÚ °ª Áß¿¡ ¼±ÅÃÇÑ ÀÚ¿øÀÇ ÇöÀç ¹üÀ§¿Í °ãÄ¡´Â °ªÀÌ ¾øÀ¸¸ç ¿äû¿¡ If-Range ¿äû Çì´õ Çʵ尡 Æ÷ÇԵǾî ÀÖÁö ¾ÊÀ¸¸é ¼¹ö¿¡¼ ÀÌ »óÅ ÄÚµå·Î ÀÀ´äÇÏ´Â °ÍÀÌ ÁÁ½À´Ï´Ù. |
static int |
HTTP_UNSUPPORTED_TYPE
415: ¿äû ¿£Æ¼Æ¼°¡ ¿äûµÈ ¸Þ¼ÒµåÀÇ ¿äû ÀÚ¿ø¿¡¼ Áö¿øÇÏÁö ¾Ê´Â Çü½ÄÀ̹ǷΠ¼¹ö¿¡¼ ¿äû 󸮸¦ °ÅºÎÇÕ´Ï´Ù. |
static int |
HTTP_USE_PROXY
305: ¿äûµÈ ÀÚ¿øÀº Location Çʵ忡 ÁöÁ¤µÈ ÇÁ·Ï½Ã¸¦ ÅëÇØ ¾×¼¼½ºÇØ¾ß ÇÕ´Ï´Ù. |
static int |
HTTP_VERSION
505: ¼¹ö¿¡¼ ¿äû ¸Þ½ÃÁö¿¡ »ç¿ëµÈ HTTP ÇÁ·ÎÅäÄÝ ¹öÀüÀ» Áö¿øÇÏÁö ¾Ê°Å³ª Áö¿øÀ» °ÅºÎÇÕ´Ï´Ù. |
static String |
POST
HTTP Post ¸Þ¼Òµå |
Method Summary | |
long |
getDate()
date Çì´õ ÇÊµå °ªÀ» ¹ÝȯÇÕ´Ï´Ù. |
long |
getExpiration()
expires Çì´õ ÇÊµå °ªÀ» ¹ÝȯÇÕ´Ï´Ù. |
String |
getFile()
HttpConnection ÀÇ URL¿¡¼ ÆÄÀÏ ºÎºÐÀ» ¹ÝȯÇÕ´Ï´Ù. |
String |
getHeaderField(int n)
»öÀÎÀ¸·Î Çì´õ ÇÊµå °ªÀ» °¡Á®¿É´Ï´Ù. |
String |
getHeaderField(String name)
¸í¸íµÈ Çì´õ ÇÊµå °ªÀ» ¹ÝȯÇÕ´Ï´Ù. |
long |
getHeaderFieldDate(String name,
long def)
³¯Â¥·Î ±¸¹® ºÐ¼®µÈ ¸í¸íµÈ ÇÊµå °ªÀ» ¹ÝȯÇÕ´Ï´Ù. |
int |
getHeaderFieldInt(String name,
int def)
¼ýÀÚ·Î ±¸¹® ºÐ¼®µÈ ¸í¸íµÈ ÇÊµå °ªÀ» ¹ÝȯÇÕ´Ï´Ù. |
String |
getHeaderFieldKey(int n)
»öÀÎÀ¸·Î Çì´õ Çʵå ۸¦ °¡Á®¿É´Ï´Ù. |
String |
getHost()
HttpConnection ÀÇ URL¿¡ ÁöÁ¤µÈ È£½ºÆ®
Á¤º¸(¿¹: È£½ºÆ® À̸§ ¶Ç´Â IPv4 ÁÖ¼Ò)¸¦ ¹ÝȯÇÕ´Ï´Ù. |
long |
getLastModified()
last-modified Çì´õ ÇÊµå °ªÀ» ¹ÝȯÇÕ´Ï´Ù.
|
int |
getPort()
ÀÌ HttpConnection ¿¡ ´ëÇÑ URLÀÇ
³×Æ®¿öÅ© Æ÷Æ® ¹øÈ£¸¦ ¹ÝȯÇÕ´Ï´Ù. |
String |
getProtocol()
HttpConnection ÀÇ URL¿¡ ÁöÁ¤µÈ ÇÁ·ÎÅäÄÝ À̸§(¿¹:
http ¶Ç´Â https)À» ¹ÝȯÇÕ´Ï´Ù. |
String |
getQuery()
HttpConnection ÀÇ
URL¿¡¼ Äõ¸® ºÎºÐÀ» ¹ÝȯÇÕ´Ï´Ù.
|
String |
getRef()
HttpConnection ÀÇ URL¿¡¼ ÂüÁ¶ ºÎºÐÀ» ¹ÝȯÇÕ´Ï´Ù.
|
String |
getRequestMethod()
ÇöÀç ¿äû ¸Þ¼Òµå(¿¹: HEAD, GET, POST)¸¦ °¡Á®¿É´Ï´Ù. |
String |
getRequestProperty(String key)
ÀÌ ¿¬°áÀÇ ¸í¸íµÈ ÀÏ¹Ý ¿äû µî·Ï Á¤º¸ °ªÀ» ¹ÝȯÇÕ´Ï´Ù. |
int |
getResponseCode()
HTTP ÀÀ´ä »óÅ Äڵ带 ¹ÝȯÇϸç, ÀÀ´äÀ» ´ÙÀ½°ú °°ÀÌ ±¸¹® ºÐ¼®ÇÕ´Ï´Ù. |
String |
getResponseMessage()
ÀÀ´ä ÄÚµå¿Í ÇÔ²² ¼¹ö¿¡¼ ¹ÝȯµÈ HTTP ÀÀ´ä ¸Þ½ÃÁö¸¦ °¡Á®¿É´Ï´Ù. |
String |
getURL()
ÀÌ ¿¬°á¿¡ ´ëÇÑ URLÀÇ ¹®ÀÚ¿ Ç¥ÇöÀ» ¹ÝȯÇÕ´Ï´Ù. |
void |
setRequestMethod(String method)
URL ¿äû ¸Þ¼Òµå¸¦ ´ÙÀ½ Áß Çϳª·Î ¼³Á¤ÇÕ´Ï´Ù. |
void |
setRequestProperty(String key,
String value)
ÀÏ¹Ý ¿äû µî·Ï Á¤º¸¸¦ ¼³Á¤ÇÕ´Ï´Ù. |
Methods inherited from interface javax.microedition.io.ContentConnection |
getEncoding, getLength, getType |
Methods inherited from interface javax.microedition.io.InputConnection |
openDataInputStream, openInputStream |
Methods inherited from interface javax.microedition.io.Connection |
close |
Methods inherited from interface javax.microedition.io.OutputConnection |
openDataOutputStream, openOutputStream |
Field Detail |
public static final String HEAD
public static final String GET
public static final String POST
public static final int HTTP_OK
public static final int HTTP_CREATED
public static final int HTTP_ACCEPTED
public static final int HTTP_NOT_AUTHORITATIVE
public static final int HTTP_NO_CONTENT
public static final int HTTP_RESET
public static final int HTTP_PARTIAL
public static final int HTTP_MULT_CHOICE
public static final int HTTP_MOVED_PERM
public static final int HTTP_MOVED_TEMP
Location
Çì´õ´Â
ÀÀ¿ë ÇÁ·Î±×·¥ÀÌ ¿äûÀ» ´Ù½Ã º¸³»¾ß ÇÏ´Â
À§Ä¡¸¦ ³ªÅ¸³À´Ï´Ù.)
public static final int HTTP_SEE_OTHER
public static final int HTTP_NOT_MODIFIED
public static final int HTTP_USE_PROXY
public static final int HTTP_TEMP_REDIRECT
public static final int HTTP_BAD_REQUEST
public static final int HTTP_UNAUTHORIZED
public static final int HTTP_PAYMENT_REQUIRED
public static final int HTTP_FORBIDDEN
public static final int HTTP_NOT_FOUND
public static final int HTTP_BAD_METHOD
public static final int HTTP_NOT_ACCEPTABLE
public static final int HTTP_PROXY_AUTH
public static final int HTTP_CLIENT_TIMEOUT
public static final int HTTP_CONFLICT
public static final int HTTP_GONE
public static final int HTTP_LENGTH_REQUIRED
public static final int HTTP_PRECON_FAILED
public static final int HTTP_ENTITY_TOO_LARGE
public static final int HTTP_REQ_TOO_LONG
public static final int HTTP_UNSUPPORTED_TYPE
public static final int HTTP_UNSUPPORTED_RANGE
public static final int HTTP_EXPECT_FAILED
public static final int HTTP_INTERNAL_ERROR
public static final int HTTP_NOT_IMPLEMENTED
public static final int HTTP_BAD_GATEWAY
public static final int HTTP_UNAVAILABLE
public static final int HTTP_GATEWAY_TIMEOUT
public static final int HTTP_VERSION
Method Detail |
public String getURL()
public String getProtocol()
HttpConnection
ÀÇ URL¿¡ ÁöÁ¤µÈ ÇÁ·ÎÅäÄÝ À̸§(¿¹:
http ¶Ç´Â https)À» ¹ÝȯÇÕ´Ï´Ù.
HttpConnection
ÀÇ URL¿¡ ÁöÁ¤µÈ ÇÁ·ÎÅäÄÝpublic String getHost()
HttpConnection
ÀÇ URL¿¡ ÁöÁ¤µÈ È£½ºÆ®
Á¤º¸(¿¹: È£½ºÆ® À̸§ ¶Ç´Â IPv4 ÁÖ¼Ò)¸¦ ¹ÝȯÇÕ´Ï´Ù.
HttpConnection
ÀÇ
URL¿¡ ÁöÁ¤µÈ È£½ºÆ® Á¤º¸public String getFile()
HttpConnection
ÀÇ URL¿¡¼ ÆÄÀÏ ºÎºÐÀ» ¹ÝȯÇÕ´Ï´Ù.
HttpConnection
ÀÇ URL¿¡¼ ÆÄÀÏ ºÎºÐ.
ÆÄÀÏÀÌ ¾øÀ¸¸é null
ÀÌ ¹ÝȯµË´Ï´Ù.public String getRef()
HttpConnection
ÀÇ URL¿¡¼ ÂüÁ¶ ºÎºÐÀ» ¹ÝȯÇÕ´Ï´Ù.
RFC2396Àº ¼±Åà »çÇ×ÀÎ Á¶°¢ ½Äº°ÀÚ¸¦ URL¿¡¼ ±³Â÷ ¹«´Ì(#)
¹®ÀÚ µÚÀÇ ÅØ½ºÆ®·Î ±ÔÁ¤ÇÕ´Ï´Ù.
»ç¿ëÀÚ ¿¡ÀÌÀüÆ®´Â ÀÌ Á¤º¸¸¦ ÀÚ¿øÀÌ ¼º°øÀûÀ¸·Î °Ë»öµÈ ÈÄÀÇ Ãß°¡ ÂüÁ¶ Á¤º¸·Î
»ç¿ëÇÒ ¼öµµ ÀÖ½À´Ï´Ù.
Á¶°¢ ½Äº°ÀÚÀÇ Çü½Ä°ú ÇØ¼®Àº °Ë»öµÈ Á¤º¸ÀÇ
¹Ìµð¾î À¯Çü[RFC2046]¿¡ µû¶ó ´Þ¶óÁý´Ï´Ù.
HttpConnection
ÀÇ URL¿¡¼ ÂüÁ¶ ºÎºÐ.
°ªÀÌ ¾øÀ¸¸é null
ÀÌ ¹ÝȯµË´Ï´Ù.public String getQuery()
HttpConnection
ÀÇ
URL¿¡¼ Äõ¸® ºÎºÐÀ» ¹ÝȯÇÕ´Ï´Ù.
RFC2396Àº Äõ¸® ±¸¼º ¿ä¼Ò¸¦ URL¿¡¼ ù ¹øÂ° ¹°À½Ç¥(?) ¹®ÀÚ µÚÀÇ
ÅØ½ºÆ®·Î Á¤ÀÇÇÕ´Ï´Ù.
HttpConnection
ÀÇ
URL¿¡¼ Äõ¸® ºÎºÐ. °ªÀÌ ¾øÀ¸¸é
null
ÀÌ ¹ÝȯµË´Ï´Ù.public int getPort()
HttpConnection
¿¡ ´ëÇÑ URLÀÇ
³×Æ®¿öÅ© Æ÷Æ® ¹øÈ£¸¦ ¹ÝȯÇÕ´Ï´Ù.
HttpConnection
¿¡ ´ëÇÑ
URLÀÇ ³×Æ®¿öÅ© Æ÷Æ® ¹øÈ£.
Connector.open
¿¡ Àü´ÞµÈ ¹®ÀÚ¿¿¡ Æ÷Æ® ¹øÈ£°¡ ¾øÀ¸¸é
±âº» HTTP Æ÷Æ® ¹øÈ£(80)°¡ ¹ÝȯµË´Ï´Ù.public String getRequestMethod()
setRequestMethod(java.lang.String)
public void setRequestMethod(String method) throws IOException
method
- HTTP ¸Þ¼Òµå
IOException
- ¸Þ¼Òµå¸¦ Àç¼³Á¤ÇÒ ¼ö ¾ø°Å³ª
¿äûµÈ ¸Þ¼Òµå°¡ HTTP¿¡ À¯È¿ÇÏÁö ¾ÊÀº °æ¿ìgetRequestMethod()
public String getRequestProperty(String key)
key
- ¿äû µî·Ï Á¤º¸¸¦ ¾Ë·ÁÁִ Ű¿öµå(¿¹:
"accept")
null
ÀÌ ¹ÝȯµË´Ï´Ù.setRequestProperty(java.lang.String, java.lang.String)
public void setRequestProperty(String key, String value) throws IOException
ÁÖ: HTTP¿¡¼ ¿©·¯ ÀνºÅϽº°¡ À¯È¿ÇÏ°Ô µ¿ÀÏÇÑ Å°¸¦ °¡Áú ¼ö ÀÖ´Â ¸ðµç ¿äû µî·Ï Á¤º¸´Â ´ÜÀÏ µî·Ï Á¤º¸¿¡ ¿©·¯ µî·Ï Á¤º¸¸¦ Ãß°¡ÇÒ ¼ö ÀÖµµ·Ï ½°Ç¥·Î ±¸ºÐµÈ ¸ñ·Ï ±¸¹®À» »ç¿ëÇØ¾ß ÇÕ´Ï´Ù.
key
- ¿äûÀ» ¾Ë·ÁÁִ Ű¿öµå(¿¹:
"accept
")value
- ¿¬°áµÈ °ª
IOException
- ¿¬°á »óŰ¡
¿¬°áµÊÀÎ °æ¿ìgetRequestProperty(java.lang.String)
public int getResponseCode() throws IOException
HTTP/1.0 200 OK HTTP/1.0 401 Unauthorized¶ÇÇÑ ÀÀ´ä¿¡¼ °¢°¢ Á¤¼ö 200°ú 401À» ÃßÃâÇÕ´Ï´Ù(¿¹: ÀÀ´äÀÌ À¯È¿ÇÑ HTTP°¡ ¾Æ´Ñ °æ¿ì).
IOException
- ¼¹ö¿¡ ¿¬°áÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ìpublic String getResponseMessage() throws IOException
HTTP/1.0 200 OK HTTP/1.0 404 Not Found¿©±â¼ °¢°¢ ¹®ÀÚ¿ "OK"¿Í "Not Found"¸¦ ÃßÃâÇÕ´Ï´Ù. ÀÀ´ä¿¡¼ ¾Æ¹« °Íµµ È®ÀÎÇÒ ¼ö ¾øÀ¸¸é nullÀ» ¹ÝȯÇÕ´Ï´Ù(°á°ú°¡ À¯È¿ÇÑ HTTP°¡ ¾Æ´Ñ °æ¿ì).
null
IOException
- ¼¹ö¿¡ ¿¬°áÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ìpublic long getExpiration() throws IOException
expires
Çì´õ ÇÊµå °ªÀ» ¹ÝȯÇÕ´Ï´Ù.
IOException
- ¼¹ö¿¡ ¿¬°áÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ìpublic long getDate() throws IOException
date
Çì´õ ÇÊµå °ªÀ» ¹ÝȯÇÕ´Ï´Ù.
0
.
¹ÝȯµÈ °ªÀº 1970³â 1¿ù 1ÀÏ GMT ÀÌÈÄÀÇ ¹Ð¸®ÃÊ ¼öÀÔ´Ï´Ù.
IOException
- ¼¹ö¿¡ ¿¬°áÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ìpublic long getLastModified() throws IOException
last-modified
Çì´õ ÇÊµå °ªÀ» ¹ÝȯÇÕ´Ï´Ù.
°á°ú´Â 1970³â 1¿ù 1ÀÏ GMT ÀÌÈÄÀÇ ¹Ð¸®ÃÊ ¼öÀÔ´Ï´Ù.
HttpConnection
ÀÌ ÂüÁ¶ÇÏ´Â ÀÚ¿øÀÌ
¸¶Áö¸·À¸·Î ¼öÁ¤µÈ ³¯Â¥ ¶Ç´Â
³¯Â¥¸¦ ¾Ë ¼ö ¾ø´Â °æ¿ì 0
IOException
- ¼¹ö¿¡ ¿¬°áÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ìpublic String getHeaderField(String name) throws IOException
name
- Çì´õ ÇʵåÀÇ À̸§
null
IOException
- ¼¹ö¿¡ ¿¬°áÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ìpublic int getHeaderFieldInt(String name, int def) throws IOException
ÀϺΠ¿¬°á À¯Çü(¿¹: http-ng
)¿¡´Â
¹Ì¸® ±¸¹® ºÐ¼®µÈ Çì´õ°¡ Àֱ⠶§¹®¿¡
ÀÌ·¯ÇÑ ¾ç½ÄÀÇ getHeaderField
°¡ »ç¿ëµË´Ï´Ù.
ÇØ´ç ¿¬°á À¯ÇüÀÇ Å¬·¡½º´Â ÀÌ ¸Þ¼Òµå¸¦ ¹«½ÃÇÏ°í ±¸¹® ºÐ¼®À» ÇÇÇÒ ¼ö ÀÖ½À´Ï´Ù.
name
- Çì´õ ÇʵåÀÇ À̸§def
- ±âº»°ª
def
°ªÀÌ ¹ÝȯµË´Ï´Ù.
IOException
- ¼¹ö¿¡ ¿¬°áÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ìpublic long getHeaderFieldDate(String name, long def) throws IOException
ÀϺΠ¿¬°á À¯Çü(¿¹: http-ng
)¿¡´Â
¹Ì¸® ±¸¹® ºÐ¼®µÈ Çì´õ°¡ Àֱ⠶§¹®¿¡
ÀÌ·¯ÇÑ ¾ç½ÄÀÇ getHeaderField
°¡ »ç¿ëµË´Ï´Ù.
ÇØ´ç ¿¬°á À¯ÇüÀÇ Å¬·¡½º´Â ÀÌ ¸Þ¼Òµå¸¦ ¹«½ÃÇÏ°í ±¸¹® ºÐ¼®À» ÇÇÇÒ ¼ö ÀÖ½À´Ï´Ù.
name
- Çì´õ ÇʵåÀÇ À̸§def
- ±âº»°ª
def
ÀÎÀÚ °ªÀÌ ¹ÝȯµË´Ï´Ù.
IOException
- ¼¹ö¿¡ ¿¬°áÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ìpublic String getHeaderField(int n) throws IOException
n
- Çì´õ ÇʵåÀÇ »öÀÎ
null
.
Çʵ忡 °ªÀÌ ¾øÀ¸¸é ºó ¹®ÀÚ¿ÀÌ ¹ÝȯµË´Ï´Ù.
IOException
- ¼¹ö¿¡ ¿¬°áÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ìpublic String getHeaderFieldKey(int n) throws IOException
n
- Çì´õ ÇʵåÀÇ »öÀÎ
null
IOException
- ¼¹ö¿¡ ¿¬°áÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ì
|
MID ÇÁ·ÎÇÊ | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |