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 void
addAllowedMethod(HttpMethod httpMethod)
OPTION Method으로 요청이 왔을 시 해당 URL로 사용할 수 있는 HttpMethod를 추가한다.void
addCookies(Cookie cookie)
쿠키 정보를 추가한다.void
allowedMethods()
지원하는 method들을 응답한다.void
badRequest()
잘못된 요청에 대한 처리를 한다.void
execute(java.lang.String pathOrJson, HttpStatus httpStatus)
HTTP 응답 메시지를 만든다.void
favicon()
파비콘에 대한 요청을 처리 한다.java.lang.Object
getHeader(java.lang.String key)
헤더 정보를 반환한다.java.util.Set<java.lang.String>
getHeaderNames()
모든 헤더의 이름을 반환한다.void
indexFile()
루트 경로의 요청을 처리한다.void
methodNotAllowed()
요청한 URL이 일치하는 핸들러는 있지만 HTTP Method가 일치하지 않을 때에 대한 처리를 한다.void
notFound()
찾는 정적 자원이 존재하지 않을시 처리한다.static Response
of(java.io.OutputStream os, java.lang.String requestPath, HttpMethod requestMethod)
인스턴스를 생성한다.void
setContentMimeType(ContentType contentMimeType)
응답할 미디어 타입을 설정한다.void
setHeader(java.lang.String key, java.lang.String value)
헤더 정보를 추가한다.void
staticResources()
정적 자원에 대한 처리를 한다.
-
-
-
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:Response
HTTP 응답 메시지를 만든다.
-
setContentMimeType
public void setContentMimeType(ContentType contentMimeType)
Description copied from interface:Response
응답할 미디어 타입을 설정한다.- Specified by:
setContentMimeType
in interfaceResponse
- Parameters:
contentMimeType
- 미디어 타입- See Also:
ContentType
-
addCookies
public void addCookies(Cookie cookie)
Description copied from interface:Response
쿠키 정보를 추가한다.- Specified by:
addCookies
in 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:
setHeader
in interfaceResponse
- Parameters:
key
- 헤더명value
- 헤더값- See Also:
HttpHeader
-
getHeader
public java.lang.Object getHeader(java.lang.String key)
Description copied from interface:Response
헤더 정보를 반환한다.- Specified by:
getHeader
in interfaceResponse
- Parameters:
key
- 헤더명- Returns:
- 헤더
- See Also:
HttpHeader
-
getHeaderNames
public java.util.Set<java.lang.String> getHeaderNames()
Description copied from interface:Response
모든 헤더의 이름을 반환한다.- Specified by:
getHeaderNames
in interfaceResponse
- Returns:
- 헤더 이름 리스트
- See Also:
HttpHeader
-
staticResources
public void staticResources()
Description copied from interface:Response
정적 자원에 대한 처리를 한다.- Specified by:
staticResources
in interfaceResponse
- See Also:
Response.execute(String, HttpStatus)
-
notFound
public void notFound()
Description copied from interface:Response
찾는 정적 자원이 존재하지 않을시 처리한다.- Specified by:
notFound
in interfaceResponse
- See Also:
Response.execute(String, HttpStatus)
-
badRequest
public void badRequest()
Description copied from interface:Response
잘못된 요청에 대한 처리를 한다.- Specified by:
badRequest
in interfaceResponse
- See Also:
Response.execute(String, HttpStatus)
-
methodNotAllowed
public void methodNotAllowed()
Description copied from interface:Response
요청한 URL이 일치하는 핸들러는 있지만 HTTP Method가 일치하지 않을 때에 대한 처리를 한다.- Specified by:
methodNotAllowed
in interfaceResponse
- See Also:
Response.execute(String, HttpStatus)
-
indexFile
public void indexFile()
Description copied from interface:Response
루트 경로의 요청을 처리한다.- Specified by:
indexFile
in interfaceResponse
- See Also:
Response.execute(String, HttpStatus)
-
favicon
public void favicon() throws ResourcesNotFoundException
Description copied from interface:Response
파비콘에 대한 요청을 처리 한다.- Specified by:
favicon
in interfaceResponse
- Throws:
ResourcesNotFoundException
- See Also:
Response.execute(String, HttpStatus)
-
addAllowedMethod
public void addAllowedMethod(HttpMethod httpMethod)
Description copied from interface:Response
OPTION Method으로 요청이 왔을 시 해당 URL로 사용할 수 있는 HttpMethod를 추가한다.- Specified by:
addAllowedMethod
in interfaceResponse
- Parameters:
httpMethod
- 추가할 HTTP Method- See Also:
HttpMethod
-
allowedMethods
public void allowedMethods()
Description copied from interface:Response
지원하는 method들을 응답한다.- Specified by:
allowedMethods
in interfaceResponse
- See Also:
Response.execute(String, HttpStatus)
-
-