Beispiel #1
0
 protected String parseSessionId(Header cookie) {
   if (cookie == null) {
     return null;
   }
   String cookieValue = cookie.getValue();
   List<String> parts = StringUtil.splitTrim(cookieValue, ";");
   for (String part : parts) {
     if (StringUtil.isEmpty(part)) {
       continue;
     }
     String lowerCase = part.toLowerCase();
     if (lowerCase.startsWith(JSESSION_STR)) {
       return part.substring(JSESSION_STR.length());
     }
   }
   return null;
 }
Beispiel #2
0
 @Override
 public Response execute(Request request) {
   if (!(request instanceof HttpRemoteRequest)) {
     throw new IllegalArgumentException("必须是HttpRequest才能执行!,参数是:" + request);
   }
   try {
     // 添加用户来源标记
     request.addParameter("userRefer", 1);
     HttpRemoteRequest httpRequest = (HttpRemoteRequest) request;
     HttpRequestBase httpRequestBase = asHttpRequest(httpRequest);
     String sessionId = request.getSessionId();
     if (!StringUtil.isEmpty(sessionId)) {
       httpRequestBase.addHeader("Cookie", JSESSION_STR + sessionId);
     }
     return handleHttpRequest(httpRequestBase);
   } catch (IOException e) {
     Log.e("HttpRemoteManager", "execute http", e);
     return new Response(MessageCodes.CONNECT_FAILED, "连接服务器失败");
   }
 }