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


Java HttpURLConnection.HTTP_ACCEPTED属性代码示例

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


在下文中一共展示了HttpURLConnection.HTTP_ACCEPTED属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
}
 
开发者ID:avinassh,项目名称:little-finger-android,代码行数:14,代码来源:LittleFinger.java

示例2: handleResponse

/**
 * @return a URL to continue pushing the BLOB to, or {@code null} if the BLOB already exists on
 *     the registry
 */
@Nullable
@Override
public String handleResponse(Response response) throws RegistryErrorException {
  switch (response.getStatusCode()) {
    case HttpStatusCodes.STATUS_CODE_CREATED:
      // The BLOB exists in the registry.
      return null;

    case HttpURLConnection.HTTP_ACCEPTED:
      return extractLocationHeader(response);

    default:
      throw buildRegistryErrorException(
          "Received unrecognized status code " + response.getStatusCode());
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:minikube-build-tools-for-java,代码行数:20,代码来源:BlobPusher.java

示例3: sendRequest

private boolean sendRequest(String url, String content) {
    LogUtils.d(TAG, "------url = " + url + "\ncontent = " + content);

    try {
        HttpURLConnection httpConn = new HttpURLConnectionBuilder(url)
                .setRequestMethod("POST")
                .setHeader("Content-Type", "application/x-gzip")
                .setHeader("Content-Encoding", "gzip")
                .setRequestBody(content)
                .setGzip(true)
                .build();

        int responseCode = httpConn.getResponseCode();
        boolean successful = (responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_OK);
        return successful;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:pre-dem,项目名称:pre-dem-android,代码行数:20,代码来源:HttpMonitorManager.java

示例4: sendRequest

private boolean sendRequest(String url, String content) {
    LogUtils.d(TAG, "----url:" + url + "\tcontent:" + content);
    try {
        HttpURLConnection httpConn = new HttpURLConnectionBuilder(url)
                .setRequestMethod("POST")
                .setHeader("Content-Type", "application/json")
                .setRequestBody(content)
                .build();

        int responseCode = httpConn.getResponseCode();
        boolean successful = (responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_OK);
        return successful;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:pre-dem,项目名称:pre-dem-android,代码行数:17,代码来源:DEMImpl.java

示例5: close

@Override
public void close() throws IOException {
    try {
        if (writer != null) {
            writer.close();
        }
    } catch (IOException e) {
        LOG.error("Error closing writer", e);
    } finally {
        this.writer = null;
        this.exporter = null;
    }

    int response = connection.getResponseCode();
    if (response != HttpURLConnection.HTTP_ACCEPTED) {
        throw new IOException("Response code from " + hostname + " was " + response);
    }
    connection.disconnect();
    this.connection = null;
}
 
开发者ID:dhatim,项目名称:dropwizard-prometheus,代码行数:20,代码来源:Pushgateway.java

示例6: checkStatusCode

private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:HttpTransportPipe.java

示例7: extractToken

/**
 * Helper method that extracts an authentication token received from a connection.
 * <p>
 * This method is used by {@link Authenticator} implementations.
 *
 * @param conn connection to extract the authentication token from.
 * @param token the authentication token.
 *
 * @throws IOException if an IO error occurred.
 * @throws AuthenticationException if an authentication exception occurred.
 */
public static void extractToken(HttpURLConnection conn, Token token) throws IOException, AuthenticationException {
  int respCode = conn.getResponseCode();
  if (respCode == HttpURLConnection.HTTP_OK
      || respCode == HttpURLConnection.HTTP_CREATED
      || respCode == HttpURLConnection.HTTP_ACCEPTED) {
    Map<String, List<String>> headers = conn.getHeaderFields();
    List<String> cookies = headers.get("Set-Cookie");
    if (cookies != null) {
      for (String cookie : cookies) {
        if (cookie.startsWith(AUTH_COOKIE_EQ)) {
          String value = cookie.substring(AUTH_COOKIE_EQ.length());
          int separator = value.indexOf(";");
          if (separator > -1) {
            value = value.substring(0, separator);
          }
          if (value.length() > 0) {
            token.set(value);
          }
        }
      }
    }
  } else {
    token.set(null);
    throw new AuthenticationException("Authentication failed, status: " + conn.getResponseCode() +
                                      ", message: " + conn.getResponseMessage());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:AuthenticatedURL.java

示例8: report

private void report(String filename, String key) {
    //3、上报服务器
    HttpURLConnection url = null;
    boolean successful = false;
    try {
        JSONObject parameters = new JSONObject();

        parameters.put("app_bundle_id", AppBean.APP_PACKAGE);
        parameters.put("app_name", AppBean.APP_NAME);
        parameters.put("app_version", AppBean.APP_VERSION);
        parameters.put("device_model", AppBean.PHONE_MODEL);
        parameters.put("os_platform", AppBean.ANDROID_PLATFORM);
        parameters.put("os_version", AppBean.ANDROID_VERSION);
        parameters.put("os_build", AppBean.ANDROID_BUILD);
        parameters.put("sdk_version", AppBean.SDK_VERSION);
        parameters.put("sdk_id", AppBean.SDK_ID);
        parameters.put("device_id", AppBean.DEVICE_IDENTIFIER);
        parameters.put("tag", AppBean.APP_TAG);
        parameters.put("manufacturer", AppBean.PHONE_MANUFACTURER);
        parameters.put("start_time", mStartTime);
        parameters.put("end_time", mEndTime);
        parameters.put("log_key", key);
        parameters.put("log_tags", "");
        parameters.put("error_count", 0);

        url = new HttpURLConnectionBuilder(Configuration.getLogcatUrl())
                .setRequestMethod("POST")
                .setHeader("Content-Type", "application/json")
                .setRequestBody(parameters.toString())
                .build();

        int responseCode = url.getResponseCode();

        successful = (responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_OK);
    } catch (Exception e) {
        LogUtils.e(TAG, "----" + e.toString());
        e.printStackTrace();
    } finally {
        if (url != null) {
            url.disconnect();
        }
        if (successful) {
            mContext.deleteFile(filename);
        } else {
            LogUtils.d("-----Transmission failed, will retry on next register() call");
        }
    }
}
 
开发者ID:pre-dem,项目名称:pre-dem-android,代码行数:48,代码来源:PrintLogger.java

示例9: sendRequest

private static void sendRequest(WeakReference<Context> weakContext, String key, JSONObject bean, String list) {
    //3、上报服务器
    HttpURLConnection url = null;
    boolean successful = false;
    try {
        JSONObject parameters = new JSONObject();

        parameters.put("app_bundle_id", AppBean.APP_PACKAGE);
        parameters.put("app_name", AppBean.APP_NAME);
        parameters.put("app_version", AppBean.APP_VERSION);
        parameters.put("device_model", AppBean.PHONE_MODEL);
        parameters.put("os_platform", AppBean.ANDROID_PLATFORM);
        parameters.put("os_version", AppBean.ANDROID_VERSION);
        parameters.put("os_build", AppBean.ANDROID_BUILD);
        parameters.put("sdk_version", AppBean.SDK_VERSION);
        parameters.put("sdk_id", AppBean.SDK_ID);
        parameters.put("device_id", AppBean.DEVICE_IDENTIFIER);
        parameters.put("tag", AppBean.APP_TAG);
        parameters.put("report_uuid", bean.optString(FIELD_REPORT_UUID));
        parameters.put("crash_log_key", key);
        parameters.put("manufacturer", AppBean.PHONE_MANUFACTURER);
        parameters.put("start_time", bean.optString(FILELD_START_TIME));
        parameters.put("crash_time", bean.optString(FILELD_CRASH_TIME));

        url = new HttpURLConnectionBuilder(Configuration.getCrashUrl())
                .setRequestMethod("POST")
                .setHeader("Content-Type", "application/json")
                .setRequestBody(parameters.toString())
                .build();

        int responseCode = url.getResponseCode();

        successful = (responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_CREATED || responseCode == HttpURLConnection.HTTP_OK);
    } catch (Exception e) {
        LogUtils.e(TAG, "----" + e.toString());
        e.printStackTrace();
    } finally {
        if (url != null) {
            url.disconnect();
        }
        if (successful) {
            deleteStackTrace(weakContext, list);
        } else {
            LogUtils.d("-----Transmission failed, will retry on next register() call");
        }
    }
}
 
开发者ID:pre-dem,项目名称:pre-dem-android,代码行数:47,代码来源:CrashManager.java


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