{"record":{"id":"7cd4bdcf8a8421fd","repo":"binarywang/WxJava","slug":"url-s-param-s-7cd4bd","errorCode":null,"errorMessage":"上传失败，服务器响应空 url:%s param:%s","messagePattern":"上传失败，服务器响应空 url:(.+?) param:(.+?)","errorType":"exception","errorClass":"WxErrorException","httpStatus":null,"severity":"error","filePath":"weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorHttpComponentsImpl.java","lineNumber":61,"sourceCode":"      InnerStreamBody part = new InnerStreamBody(data.getInputStream(), ContentType.DEFAULT_BINARY, data.getFileName(), data.getLength());\n      MultipartEntityBuilder entityBuilder = MultipartEntityBuilder\n        .create()\n        .addPart(param.getName(), part)\n        .setMode(HttpMultipartMode.EXTENDED);\n\n      // 添加额外的表单字段\n      if (param.getFormFields() != null && !param.getFormFields().isEmpty()) {\n        for (java.util.Map.Entry<String, String> entry : param.getFormFields().entrySet()) {\n          entityBuilder.addTextBody(entry.getKey(), entry.getValue(), ContentType.TEXT_PLAIN.withCharset(\"UTF-8\"));\n        }\n      }\n\n      HttpEntity entity = entityBuilder.build();\n      httpPost.setEntity(entity);\n    }\n    String responseContent = requestHttp.getRequestHttpClient().execute(httpPost, Utf8ResponseHandler.INSTANCE);\n    if (StringUtils.isEmpty(responseContent)) {\n      throw new WxErrorException(String.format(\"上传失败，服务器响应空 url:%s param:%s\", uri, param));\n    }\n    WxError error = WxError.fromJson(responseContent, wxType);\n    if (error.getErrorCode() != 0) {\n      throw new WxErrorException(error);\n    }\n    return responseContent;\n  }\n\n  /**\n   * 内部流 请求体\n   */\n  @Getter\n  public static class InnerStreamBody extends InputStreamBody {\n\n    private final long contentLength;\n\n    public InnerStreamBody(final InputStream in, final ContentType contentType, final String filename, long contentLength) {\n      super(in, contentType, filename);","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-common/src/main/java/me/chanjar/weixin/common/executor/CommonUploadRequestExecutorHttpComponentsImpl.java#L43-L79","documentation":"The Apache HttpComponents (5.x) upload executor throws when the server returns an empty response body after a multipart POST. Identical semantics to the 4.x Apache variant (error 28): no parseable body means a fast-fail with URL and param. This is the 5.x-flavoured implementation.","triggerScenarios":"WeChat or a configured proxy returns HTTP 200 with an empty body to the HttpComponents 5.x client during an upload; gateway/WAF stripping; silent upstream body-size enforcement.","commonSituations":"Using HTTP_COMPONENTS backend and hitting an infra layer that returns empty; large-file uploads exceeding a proxy limit; transient connection resets.","solutions":["Retry the upload — empty bodies are frequently transient.","Check apiHostUrl/proxy configuration and body-size limits.","Log the HTTP status and headers (not the body, which is empty) to localise the layer dropping the response.","Confirm payload size is within endpoint limits."],"exampleFix":"// before\nString r = service.upload(param);\n\n// after — guard + retry\ntry {\n  return service.upload(param);\n} catch (WxErrorException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"服务器响应空\")) {\n    Thread.sleep(1000);\n    return service.upload(param);\n  }\n  throw e;\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"int attempts = 0;\nwhile (true) {\n  try {\n    return service.upload(param);\n  } catch (WxErrorException e) {\n    boolean empty = e.getMessage() != null && e.getMessage().contains(\"服务器响应空\");\n    if (!empty || ++attempts > 2) throw e;\n    Thread.sleep(1000L * attempts);\n  }\n}","preventionTips":["Check the HttpComponents 5.x client's proxy/apiHostUrl configuration.","Ensure upload size is within endpoint limits.","Log response status/headers to find the layer returning an empty body."],"tags":["upload","http-components","empty-response","network","transient"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}