当前位置: 首页>>代码示例>>Java>>正文


Java HttpStatus.SC_NO_CONTENT属性代码示例

本文整理汇总了Java中org.apache.http.HttpStatus.SC_NO_CONTENT属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.SC_NO_CONTENT属性的具体用法?Java HttpStatus.SC_NO_CONTENT怎么用?Java HttpStatus.SC_NO_CONTENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.http.HttpStatus的用法示例。


在下文中一共展示了HttpStatus.SC_NO_CONTENT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkBatchResponseBody

/**
 * 不正な認証情報を使用してすべてのユーザがアクセス可能なコレクションに対して$batchをした場合処理が受付けられること.
 * batchの実行順
 * 1.POST(登録)
 * 2.GET(一覧取得)
 * 3.GET(取得)
 * 4.PUT(更新)
 * 5.DELETE(削除)
 */
@Test
public final void 不正な認証情報を使用してすべてのユーザがアクセス可能なコレクションに対して$batchをした場合処理が受付けられること() {

    // 認証トークン取得
    String invalidToken = "invalid token";

    // ACL設定
    String path = String.format("%s/%s/%s", TEST_CELL1, BOX_NAME, COL_NAME);
    DavResourceUtils.setACLPrivilegeAllForAllUser(TEST_CELL1, MASTER_TOKEN, HttpStatus.SC_OK, path, "none");

    // READとWRITE→全てOK
    TResponse res = UserDataUtils.batch(TEST_CELL1, BOX_NAME, COL_NAME, BOUNDARY, TEST_BODY,
            invalidToken, HttpStatus.SC_ACCEPTED);
    // 期待するレスポンスコード
    int[] expectedCodes = new int[] {HttpStatus.SC_CREATED,
            HttpStatus.SC_OK,
            HttpStatus.SC_OK,
            HttpStatus.SC_NO_CONTENT,
            HttpStatus.SC_NO_CONTENT };
    // レスポンスボディのチェック(ステータス)
    checkBatchResponseBody(res, expectedCodes);

}
 
开发者ID:personium,项目名称:personium-core,代码行数:32,代码来源:AuthBatchTest.java

示例2: accountAuth

/**
 * 正しい認証情報を使用してread_write権限があるコレクションに対して$batchをした場合処理が受付けられること.
 * batchの実行順
 * 1.POST(登録)
 * 2.GET(一覧取得)
 * 3.GET(取得)
 * 4.PUT(更新)
 * 5.DELETE(削除)
 */
@Test
public final void 正しい認証情報を使用してread_write権限があるコレクションに対して$batchをした場合処理が受付けられること() {

    // 認証トークン取得
    String[] tokens = accountAuth();

    // ACL設定
    DavResourceUtils.setACL(TEST_CELL1, MASTER_TOKEN, HttpStatus.SC_OK, COL_NAME, ACL_AUTH_TEST_FILE, BOX_NAME, "");

    // READとWRITE→全てOK
    TResponse res = UserDataUtils.batch(TEST_CELL1, BOX_NAME, COL_NAME, BOUNDARY, TEST_BODY,
            tokens[READ_WRITE], HttpStatus.SC_ACCEPTED);
    // 期待するレスポンスコード
    int[] expectedCodes = new int[] {HttpStatus.SC_CREATED,
            HttpStatus.SC_OK,
            HttpStatus.SC_OK,
            HttpStatus.SC_NO_CONTENT,
            HttpStatus.SC_NO_CONTENT };
    // レスポンスボディのチェック(ステータス)
    checkBatchResponseBody(res, expectedCodes);

}
 
开发者ID:personium,项目名称:personium-core,代码行数:31,代码来源:AuthBatchTest.java

示例3: afterCell

/**
 * testの後に実行する.
 */
@After
public final void afterCell() {
    PersoniumResponse res = null;
    if (this.cellInfo.cellId != null) {
        if (this.cellInfo.boxName != null) {
            // テストBox 削除
            res = restDelete(UrlUtils.cellCtl(this.cellInfo.cellName, Box.EDM_TYPE_NAME, this.cellInfo.boxName));
        }
        // テストCell 削除
        res = restDelete(UrlUtils.unitCtl(Cell.EDM_TYPE_NAME, this.cellInfo.cellId));
        // レスポンスコードのチェック
        if ((res.getStatusCode() == HttpStatus.SC_NO_CONTENT)
                || (res.getStatusCode() == HttpStatus.SC_OK)) {
            this.cellInfo.initial();
        }
        assertEquals(HttpStatus.SC_NO_CONTENT, res.getStatusCode());
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:21,代码来源:DeleteTest.java

示例4: getResponseMessage

/**
 * レスポンスコードの説明を取得する.
 * @return レスポンスコードの説明(例:OK, No Content)
 */
public String getResponseMessage() {
    String message = null;

    switch (this.responseCode) {
    case HttpStatus.SC_NO_CONTENT:
        message = "No Content";
        break;

    case HttpStatus.SC_CREATED:
        message = "Created";
        break;

    case HttpStatus.SC_OK:
        message = "OK";
        break;

    default:
        message = "";
        break;
    }

    return message;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:27,代码来源:ODataBatchResource.java

示例5: onSuccess

@Override
public final void onSuccess(final int statusCode, final Header[] headers, final String responseString) {
    if (statusCode != HttpStatus.SC_NO_CONTENT) {
        Runnable parser = new Runnable() {
            @Override
            public void run() {
                try {
                    final JSON_TYPE jsonResponse = parseResponse(responseString, false);
                    postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            onSuccess(statusCode, headers, responseString, jsonResponse);
                        }
                    });
                } catch (final Throwable t) {
                    Log.d(LOG_TAG, "parseResponse thrown an problem", t);
                    postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            onFailure(statusCode, headers, t, responseString, null);
                        }
                    });
                }
            }
        };
        if (!getUseSynchronousMode()) {
            new Thread(parser).start();
        } else {
            // In synchronous mode everything should be run on one thread
            parser.run();
        }
    } else {
        onSuccess(statusCode, headers, null, null);
    }
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:35,代码来源:BaseJsonHttpResponseHandler.java

示例6: executeAbstractMethod

private void executeAbstractMethod(HttpUriRequest request) throws CamundaRestException,IOException{
    HttpResponse response = httpClient.execute(request);
    StringWriter stringWriter = new StringWriter();
    int statusCode = response.getStatusLine().getStatusCode();
    if (response.getEntity() != null
            && response.getEntity().getContent() != null) {
        IOUtils.copy(response.getEntity().getContent(), stringWriter);
    }
    if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_NO_CONTENT) {
        throw CamundaRestException.fromCodeAndResponse(statusCode,stringWriter.toString());
    }
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:12,代码来源:ExternalTaskRestServiceImpl.java

示例7: canResponseHaveBody

/**
 * Decide whether a response comes with an entity.
 * The implementation in this class is based on RFC 2616.
 * <br/>
 * Derived executors can override this method to handle
 * methods and response codes not specified in RFC 2616.
 *
 * @param request   the request, to obtain the executed method
 * @param response  the response, to obtain the status code
 */
protected boolean canResponseHaveBody(final HttpRequest request,
                                      final HttpResponse response) {

    if ("HEAD".equalsIgnoreCase(request.getRequestLine().getMethod())) {
        return false;
    }
    int status = response.getStatusLine().getStatusCode();
    return status >= HttpStatus.SC_OK
        && status != HttpStatus.SC_NO_CONTENT
        && status != HttpStatus.SC_NOT_MODIFIED
        && status != HttpStatus.SC_RESET_CONTENT;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:HttpRequestExecutor.java

示例8: onSuccess

@Override
public void onSuccess(final int statusCode, final Header[] headers, final String responseBody) {
    if (statusCode != HttpStatus.SC_NO_CONTENT) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    final JSON_TYPE jsonResponse = parseResponse(responseBody);
                    postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            onSuccess(statusCode, headers, responseBody, jsonResponse);
                        }
                    });
                } catch (final Throwable t) {
                    postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            onFailure(statusCode, headers, t, responseBody, null);
                        }
                    });
                }
            }
        }).start();
    } else {
        onSuccess(statusCode, headers, null, null);
    }
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:28,代码来源:BaseJsonHttpResponseHandler.java

示例9: onSuccess

@Override
public final void onSuccess(final int statusCode, final Header[] headers, final String responseString) {
    if (statusCode != HttpStatus.SC_NO_CONTENT) {
        Runnable parser = new Runnable() {
            @Override
            public void run() {
                try {
                    final JSON_TYPE jsonResponse = parseResponse(responseString, false);
                    postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            onSuccess(statusCode, headers, responseString, jsonResponse);
                        }
                    });
                } catch (final Throwable t) {
                    Log.d(LOG_TAG, "parseResponse thrown an problem", t);
                    postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            onFailure(statusCode, headers, t, responseString, null);
                        }
                    });
                }
            }
        };
        if (!getUseSynchronousMode())
            new Thread(parser).start();
        else // In synchronous mode everything should be run on one thread
            parser.run();
    } else {
        onSuccess(statusCode, headers, null, null);
    }
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:33,代码来源:BaseJsonHttpResponseHandler.java

示例10: onSuccess

@Override
public void onSuccess(final int statusCode, final Header[] headers, final String responseBody) {
    if (statusCode != HttpStatus.SC_NO_CONTENT) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    final Object jsonResponse = parseResponse(responseBody);
                    postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            if (jsonResponse instanceof JSONObject) {
                                onSuccess(statusCode, headers, (JSONObject) jsonResponse);
                            } else if (jsonResponse instanceof JSONArray) {
                                onSuccess(statusCode, headers, (JSONArray) jsonResponse);
                            } else if (jsonResponse instanceof String) {
                                onSuccess(statusCode, headers, (String) jsonResponse);
                            } else {
                                onFailure(new JSONException("Unexpected type " + jsonResponse.getClass().getName()), (JSONObject) null);
                            }

                        }
                    });
                } catch (final JSONException ex) {
                    postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            onFailure(ex, (JSONObject) null);
                        }
                    });
                }
            }
        }).start();
    } else {
        onSuccess(statusCode, headers, new JSONObject());
    }
}
 
开发者ID:zqHero,项目名称:rongyunDemo,代码行数:37,代码来源:JsonHttpResponseHandler.java

示例11: doGet

/**
 * Executes get http request to an endpoint with provided headers.
 *
 * @param uri
 *            Endpoint that needs to be hit
 * @param headers
 *            Key value pair of headers
 * @return Return response body after executing GET
 * @throws StockException
 *             if api doesn't return with success code or when null/empty
 *             endpoint is passed in uri
 */
public static String doGet(final String uri,
        final Map<String, String> headers) throws StockException {

    if (sHttpClient == null) {
        sHttpClient = HttpUtils.initialize();
    }

    HttpResponse response = null;
    String responseBody = null;
    HttpGet request = new HttpGet();

    if (uri == null || uri.isEmpty()) {
        throw new StockException(-1, "URI cannot be null or Empty");
    }

    if (headers != null) {
        for (Entry<String, String> entry : headers.entrySet()) {
            request.setHeader(entry.getKey(), entry.getValue());
        }
    }

    try {
        request.setURI(new URI(uri));
        response = sHttpClient.execute(request);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            responseBody = EntityUtils.toString(response.getEntity());
        } else if (response.getStatusLine().getStatusCode()
                == HttpStatus.SC_NO_CONTENT) {
            responseBody = String.valueOf(HttpStatus.SC_NO_CONTENT);
        } else if (response.getStatusLine().getStatusCode()
                / HTTP_STATUS_CODE_DIVISOR
                    == HTTP_STATUS_CODE_API_ERROR) {
            responseBody = EntityUtils.toString(response.getEntity());
            throw new StockException(response.getStatusLine()
                    .getStatusCode(), responseBody);
        } else if (response.getStatusLine().getStatusCode()
                / HTTP_STATUS_CODE_DIVISOR == HTTP_STATUS_CODE_REDIRECT) {
            String locationHeader =
                    response.getHeaders("Location")[0].getValue();
            responseBody = locationHeader;
        } else if (response.getStatusLine().getStatusCode()
                / HTTP_STATUS_CODE_DIVISOR
                    == HTTP_STATUS_CODE_SERVER_ERROR) {
            throw new StockException(response.getStatusLine()
                    .getStatusCode(), "API returned with Server Error");

        }

    } catch (StockException se) {
        throw se;
    } catch (Exception ex) {
        throw new StockException(ex.getMessage());
    }

    return responseBody;
}
 
开发者ID:adobe,项目名称:stock-api-sdk,代码行数:68,代码来源:ApiUtils.java

示例12: canHandle

@Override
public boolean canHandle(Pact.InteractionResponse interactionResponse) {
    return interactionResponse.getStatus() == HttpStatus.SC_NO_CONTENT;
}
 
开发者ID:tyro,项目名称:pact-spring-mvc,代码行数:4,代码来源:StatusCodeNoContentResponseBodyMatcher.java

示例13: process

/**
 * Processes the response (possibly updating or inserting) Content-Length and Transfer-Encoding headers.
 * @param response The HttpResponse to modify.
 * @param context Unused.
 * @throws ProtocolException If either the Content-Length or Transfer-Encoding headers are found.
 * @throws IllegalArgumentException If the response is null.
 */
public void process(final HttpResponse response, final HttpContext context)
        throws HttpException, IOException {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }
    if (this.overwrite) {
        response.removeHeaders(HTTP.TRANSFER_ENCODING);
        response.removeHeaders(HTTP.CONTENT_LEN);
    } else {
        if (response.containsHeader(HTTP.TRANSFER_ENCODING)) {
            throw new ProtocolException("Transfer-encoding header already present");
        }
        if (response.containsHeader(HTTP.CONTENT_LEN)) {
            throw new ProtocolException("Content-Length header already present");
        }
    }
    ProtocolVersion ver = response.getStatusLine().getProtocolVersion();
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        long len = entity.getContentLength();
        if (entity.isChunked() && !ver.lessEquals(HttpVersion.HTTP_1_0)) {
            response.addHeader(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);
        } else if (len >= 0) {
            response.addHeader(HTTP.CONTENT_LEN, Long.toString(entity.getContentLength()));
        }
        // Specify a content type if known
        if (entity.getContentType() != null && !response.containsHeader(
                HTTP.CONTENT_TYPE )) {
            response.addHeader(entity.getContentType());
        }
        // Specify a content encoding if known
        if (entity.getContentEncoding() != null && !response.containsHeader(
                HTTP.CONTENT_ENCODING)) {
            response.addHeader(entity.getContentEncoding());
        }
    } else {
        int status = response.getStatusLine().getStatusCode();
        if (status != HttpStatus.SC_NO_CONTENT
                && status != HttpStatus.SC_NOT_MODIFIED
                && status != HttpStatus.SC_RESET_CONTENT) {
            response.addHeader(HTTP.CONTENT_LEN, "0");
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:51,代码来源:ResponseContent.java

示例14: onSuccess

@Override
public final void onSuccess(final int statusCode, final Header[] headers, final byte[] responseBytes) {
    if (statusCode != HttpStatus.SC_NO_CONTENT) {
        Runnable parser = new Runnable() {
            @Override
            public void run() {
                try {
                    final Object jsonResponse = parseResponse(responseBytes);
                    postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            if (jsonResponse instanceof JSONObject) {
                                onSuccess(statusCode, headers, (JSONObject) jsonResponse);
                            } else if (jsonResponse instanceof JSONArray) {
                                onSuccess(statusCode, headers, (JSONArray) jsonResponse);
                            } else if (jsonResponse instanceof String) {
                                onFailure(statusCode, headers, (String) jsonResponse, new JSONException("Response cannot be parsed as JSON data"));
                            } else {
                                onFailure(statusCode, headers, new JSONException("Unexpected response type " + jsonResponse.getClass().getName()), (JSONObject) null);
                            }

                        }
                    });
                } catch (final JSONException ex) {
                    postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            onFailure(statusCode, headers, ex, (JSONObject) null);
                        }
                    });
                }
            }
        };
        if (!getUseSynchronousMode()) {
            new Thread(parser).start();
        } else {
            // In synchronous mode everything should be run on one thread
            parser.run();
        }
    } else {
        onSuccess(statusCode, headers, new JSONObject());
    }
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:43,代码来源:JsonHttpResponseHandler.java

示例15: hasResponseBody

/**
 * Checks if a response message contains a body.
 * @see <a href="https://tools.ietf.org/html/rfc7230#section-3.3">RFC 7230 section 3.3</a>
 * @param requestMethod request method
 * @param responseCode response status code
 * @return whether the response has a body
 */
private static boolean hasResponseBody(int requestMethod, int responseCode) {
    return requestMethod != Request.Method.HEAD
        && !(HttpStatus.SC_CONTINUE <= responseCode && responseCode < HttpStatus.SC_OK)
        && responseCode != HttpStatus.SC_NO_CONTENT
        && responseCode != HttpStatus.SC_NOT_MODIFIED;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:HurlStack.java


注:本文中的org.apache.http.HttpStatus.SC_NO_CONTENT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。