Package org.sam.server.http.web.response
Class HttpResponse
- java.lang.Object
-
- org.sam.server.http.web.response.HttpResponse
-
- All Implemented Interfaces:
Response
public class HttpResponse extends java.lang.Object implements Response
요청을 해석하고 응답하는 클래스. 정적 자원을 반환한다.- See Also:
execute(String, HttpStatus)
-
-
Field Summary
-
Fields inherited from interface org.sam.server.http.web.response.Response
BAD_REQUEST_PAGE, BUFFER_SIZE_PROPERTY, DEFAULT_FILE_PAGE, FAVICON, METHOD_NOT_ALLOWED_PAGE, NOT_FOUND_PAGE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAllowedMethod(HttpMethod httpMethod)OPTION Method으로 요청이 왔을 시 해당 URL로 사용할 수 있는 HttpMethod를 추가한다.voidaddCookies(Cookie cookie)쿠키 정보를 추가한다.voidallowedMethods()지원하는 method들을 응답한다.voidbadRequest()잘못된 요청에 대한 처리를 한다.voidexecute(java.lang.String pathOrJson, HttpStatus httpStatus)HTTP 응답 메시지를 만든다.voidfavicon()파비콘에 대한 요청을 처리 한다.java.lang.ObjectgetHeader(java.lang.String key)헤더 정보를 반환한다.java.util.Set<java.lang.String>getHeaderNames()모든 헤더의 이름을 반환한다.voidindexFile()루트 경로의 요청을 처리한다.voidmethodNotAllowed()요청한 URL이 일치하는 핸들러는 있지만 HTTP Method가 일치하지 않을 때에 대한 처리를 한다.voidnotFound()찾는 정적 자원이 존재하지 않을시 처리한다.static Responseof(java.io.OutputStream os, java.lang.String requestPath, HttpMethod requestMethod)인스턴스를 생성한다.voidsetContentMimeType(ContentType contentMimeType)응답할 미디어 타입을 설정한다.voidsetHeader(java.lang.String key, java.lang.String value)헤더 정보를 추가한다.voidstaticResources()정적 자원에 대한 처리를 한다.
-
-
-
Method Detail
-
of
public static Response of(java.io.OutputStream os, java.lang.String requestPath, HttpMethod requestMethod)
인스턴스를 생성한다.- Parameters:
os- 응답을 출력할 스트림requestPath- 요청 URLrequestMethod- 요청 HTTP Method- Returns:
- HttpResponse 인스턴스
-
execute
public void execute(java.lang.String pathOrJson, HttpStatus httpStatus)Description copied from interface:ResponseHTTP 응답 메시지를 만든다.
-
setContentMimeType
public void setContentMimeType(ContentType contentMimeType)
Description copied from interface:Response응답할 미디어 타입을 설정한다.- Specified by:
setContentMimeTypein interfaceResponse- Parameters:
contentMimeType- 미디어 타입- See Also:
ContentType
-
addCookies
public void addCookies(Cookie cookie)
Description copied from interface:Response쿠키 정보를 추가한다.- Specified by:
addCookiesin interfaceResponse- Parameters:
cookie- 추가할 쿠키- See Also:
Cookie
-
setHeader
public void setHeader(java.lang.String key, java.lang.String value)Description copied from interface:Response헤더 정보를 추가한다.- Specified by:
setHeaderin interfaceResponse- Parameters:
key- 헤더명value- 헤더값- See Also:
HttpHeader
-
getHeader
public java.lang.Object getHeader(java.lang.String key)
Description copied from interface:Response헤더 정보를 반환한다.- Specified by:
getHeaderin interfaceResponse- Parameters:
key- 헤더명- Returns:
- 헤더
- See Also:
HttpHeader
-
getHeaderNames
public java.util.Set<java.lang.String> getHeaderNames()
Description copied from interface:Response모든 헤더의 이름을 반환한다.- Specified by:
getHeaderNamesin interfaceResponse- Returns:
- 헤더 이름 리스트
- See Also:
HttpHeader
-
staticResources
public void staticResources()
Description copied from interface:Response정적 자원에 대한 처리를 한다.- Specified by:
staticResourcesin interfaceResponse- See Also:
Response.execute(String, HttpStatus)
-
notFound
public void notFound()
Description copied from interface:Response찾는 정적 자원이 존재하지 않을시 처리한다.- Specified by:
notFoundin interfaceResponse- See Also:
Response.execute(String, HttpStatus)
-
badRequest
public void badRequest()
Description copied from interface:Response잘못된 요청에 대한 처리를 한다.- Specified by:
badRequestin interfaceResponse- See Also:
Response.execute(String, HttpStatus)
-
methodNotAllowed
public void methodNotAllowed()
Description copied from interface:Response요청한 URL이 일치하는 핸들러는 있지만 HTTP Method가 일치하지 않을 때에 대한 처리를 한다.- Specified by:
methodNotAllowedin interfaceResponse- See Also:
Response.execute(String, HttpStatus)
-
indexFile
public void indexFile()
Description copied from interface:Response루트 경로의 요청을 처리한다.- Specified by:
indexFilein interfaceResponse- See Also:
Response.execute(String, HttpStatus)
-
favicon
public void favicon() throws ResourcesNotFoundExceptionDescription copied from interface:Response파비콘에 대한 요청을 처리 한다.- Specified by:
faviconin interfaceResponse- Throws:
ResourcesNotFoundException- See Also:
Response.execute(String, HttpStatus)
-
addAllowedMethod
public void addAllowedMethod(HttpMethod httpMethod)
Description copied from interface:ResponseOPTION Method으로 요청이 왔을 시 해당 URL로 사용할 수 있는 HttpMethod를 추가한다.- Specified by:
addAllowedMethodin interfaceResponse- Parameters:
httpMethod- 추가할 HTTP Method- See Also:
HttpMethod
-
allowedMethods
public void allowedMethods()
Description copied from interface:Response지원하는 method들을 응답한다.- Specified by:
allowedMethodsin interfaceResponse- See Also:
Response.execute(String, HttpStatus)
-
-