REST API에 적용된 Http Method에 대한 질문입니다.

49 views
Skip to first unread message

Jun-Hong Park

unread,
Dec 1, 2014, 7:55:53 PM12/1/14
to open...@googlegroups.com
IRIS REST API 에는 각각 Http Method 가 정해져 있는데, 이전에도 글을 올렸는데, 2.1.5(오늘 날짜 최신)에도 변경되지 않아 다시 올립니다.

Http Method 에서 DELETE 는 Request Entity를 갖지 않습니다. (http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html)

이에 반해, 몇 군데에서 Http Method 가 DELETE 인 경우에 있어서 Request Entity에서 데이터를 획득하려는 부분이 보입니다.

FirewallStorage.java#370인 경우에는 Request.getEntityAsText() 메소드 내부에서 Request Entity에 대한 null 처리를 하고 또한 다음 부분에서도 null 을 확인하는 것을 볼 수 있지만,

StaticflowEntryStorage.java#663인 경우에는 Http Method 가 확인되지 않은 시점에서 Request.getEntityAsText() 의 결과값을 획득하고 이에 대해서 null 처리를 하지 않고 사용을 합니다.

이 부분에서 Internal Server Error가 발생합니다.

curl 를 사용할 경우 Http Method에 대한 처리 없이 Request Entity를 추가해서 보내기 때문에 curl 을 이용한 테스트 수준에서는 문제가 없지만,

RFC 표준을 준수한 라이브러리를 사용하는 경우, 라이브러리에 따라서 Http Method 가 DELETE인 경우 Request Entity를 설정하는 시점에서 예외나 에러를 발생시키거나,

그렇지 않더라도 송신하는 시점에 보내지 않습니다.

이 부분에 대한 패치가 필요해 보입니다.



1. FirewallStorage.java#370
...
else if (m == Method.DELETE){
Iterator<FirewallRule> iter = firewall.getRules().iterator();

String entityText = request.getEntityAsText();
// Clear all rules.
if (entityText == null) {
firewall.clearRules();
...


2. StaticFlowEntryStorage.java#663
...
public void handle(Request request, Response response) {
StringWriter sWriter = new StringWriter();
JsonFactory f = new JsonFactory();
JsonGenerator g = null;
String status = null;

Method m = request.getMethod();
String entityText = request.getEntityAsText();
entityText = entityText.replaceAll("[\']", "");

...
...

/*
* DELETE example
* OF1.0,1.3: curl -X DELETE -d '{"name":"s1"}' http://{controller_ip}:{rest_api_port}/wm/staticflowentry/json
*/
else if (m == Method.DELETE) {
Map<String, Object> entry;
Object flowName;

try {
entry = StaticFlowEntry.jsonToStaticFlowEntry(entityText);
flowName = entry.get("name");
if (flowName != null) {
getManager().deleteFlow((String)flowName);
status = "Entry deleted: " + flowName;
}
...


Justin Park

unread,
Dec 3, 2014, 2:09:45 AM12/3/14
to open...@googlegroups.com
좋은 지적 감사합니다.
고려해 보겠습니다.

Shin Jisoo

unread,
Dec 4, 2014, 8:39:05 PM12/4/14
to open...@googlegroups.com
일부 REST API의 예외 처리와
DELETE에 관한 REST API가 추가되었습니다.

감사합니다.


2014년 12월 3일 오후 4:09, Justin Park <justin...@gmail.com>님이 작성:

--
You received this message because you are subscribed to the Google Groups "openiris" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openiris+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/openiris.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages