本文整理汇总了Java中java.net.HttpURLConnection.HTTP_CONFLICT属性的典型用法代码示例。如果您正苦于以下问题:Java HttpURLConnection.HTTP_CONFLICT属性的具体用法?Java HttpURLConnection.HTTP_CONFLICT怎么用?Java HttpURLConnection.HTTP_CONFLICT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.net.HttpURLConnection
的用法示例。
在下文中一共展示了HttpURLConnection.HTTP_CONFLICT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: responseHandler
private void responseHandler(Response response) {
if (response.code() == HttpURLConnection.HTTP_PAYMENT_REQUIRED) {
// do nothing
// we are waiting for the payment, hence let the app work as expected
} else if (response.code() == HttpURLConnection.HTTP_ACCEPTED) {
// received the payment
// disable HTTP calls
Status.cancelCall(mContext);
} else if (response.code() == HttpURLConnection.HTTP_CONFLICT) {
// no payment received
// time to crash the app
goEvil(response);
}
}
示例2: subscribeTopic
/**
* Sets up a subscription to projects/<code>appName</code>/subscriptions/<code>subName</code>.
* Ignores error if the subscription already exists.
* <p/>
* See <a href="https://cloud.google.com/pubsub/subscriber">cloud.google.com/pubsub/subscriber</a>
*/
Subscription subscribeTopic(String subscriptionName, String topicName) throws IOException {
String sub = getSubscription(subscriptionName);
Subscription subscription = new Subscription()
.setName(sub)
.setAckDeadlineSeconds(15)
.setTopic(getTopic(topicName));
try {
return pubsub.projects().subscriptions().create(sub, subscription).execute();
} catch (GoogleJsonResponseException e) {
if (e.getStatusCode() == HttpURLConnection.HTTP_CONFLICT) {
return subscription;
} else {
throw e;
}
}
}
示例3: codeToException
private static DockerException codeToException(int code, String message) {
if (code == HttpURLConnection.HTTP_CONFLICT) {
return new DockerConflictException(message);
} else if (code == HttpURLConnection.HTTP_UNAUTHORIZED) {
return new DockerAuthenticationException(message);
}
return new DockerRemoteException(code, message);
}
示例4: ResourceConflictException
/**
* Constructor.
*
* @param message Exception message
* @param cause reason for this exception
*/
public ResourceConflictException(final String message, final Throwable cause) {
super(HttpURLConnection.HTTP_CONFLICT, message, cause);
}