|
|
@ -37,9 +37,12 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity |
|
|
|
private static final String TAG = "HttpHeaderDelegate"; |
|
|
|
private static final String TAG = "HttpHeaderDelegate"; |
|
|
|
private ENTITY mEntity; |
|
|
|
private ENTITY mEntity; |
|
|
|
private TASK_ENTITY mTaskEntity; |
|
|
|
private TASK_ENTITY mTaskEntity; |
|
|
|
|
|
|
|
private TARGET mTarget; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public HttpHeaderDelegate(TARGET target, TASK_ENTITY taskEntity) { |
|
|
|
|
|
|
|
mTarget = target; |
|
|
|
|
|
|
|
mTaskEntity = taskEntity; |
|
|
|
|
|
|
|
|
|
|
|
public HttpHeaderDelegate(TASK_ENTITY mTaskEntity) { |
|
|
|
|
|
|
|
this.mTaskEntity = mTaskEntity; |
|
|
|
|
|
|
|
mEntity = mTaskEntity.getEntity(); |
|
|
|
mEntity = mTaskEntity.getEntity(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -54,10 +57,10 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity |
|
|
|
public TARGET addHeader(@NonNull String key, @NonNull String value) { |
|
|
|
public TARGET addHeader(@NonNull String key, @NonNull String value) { |
|
|
|
if (TextUtils.isEmpty(key)) { |
|
|
|
if (TextUtils.isEmpty(key)) { |
|
|
|
ALog.w(TAG, "设置header失败,header对应的key不能为null"); |
|
|
|
ALog.w(TAG, "设置header失败,header对应的key不能为null"); |
|
|
|
return (TARGET) this; |
|
|
|
return mTarget; |
|
|
|
} else if (TextUtils.isEmpty(value)) { |
|
|
|
} else if (TextUtils.isEmpty(value)) { |
|
|
|
ALog.w(TAG, "设置header失败,header对应的value不能为null"); |
|
|
|
ALog.w(TAG, "设置header失败,header对应的value不能为null"); |
|
|
|
return (TARGET) this; |
|
|
|
return mTarget; |
|
|
|
} |
|
|
|
} |
|
|
|
if (mTaskEntity.headers.get(key) == null) { |
|
|
|
if (mTaskEntity.headers.get(key) == null) { |
|
|
|
mTaskEntity.headers.put(key, value); |
|
|
|
mTaskEntity.headers.put(key, value); |
|
|
@ -66,7 +69,7 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity |
|
|
|
mTaskEntity.headers.put(key, value); |
|
|
|
mTaskEntity.headers.put(key, value); |
|
|
|
mTaskEntity.update(); |
|
|
|
mTaskEntity.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
return (TARGET) this; |
|
|
|
return mTarget; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -79,7 +82,7 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity |
|
|
|
public TARGET addHeaders(@NonNull Map<String, String> headers) { |
|
|
|
public TARGET addHeaders(@NonNull Map<String, String> headers) { |
|
|
|
if (headers.size() == 0) { |
|
|
|
if (headers.size() == 0) { |
|
|
|
ALog.w(TAG, "设置header失败,map没有header数据"); |
|
|
|
ALog.w(TAG, "设置header失败,map没有header数据"); |
|
|
|
return (TARGET) this; |
|
|
|
return mTarget; |
|
|
|
} |
|
|
|
} |
|
|
|
/* |
|
|
|
/* |
|
|
|
两个map比较逻辑 |
|
|
|
两个map比较逻辑 |
|
|
@ -123,7 +126,7 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity |
|
|
|
mTaskEntity.update(); |
|
|
|
mTaskEntity.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return (TARGET) this; |
|
|
|
return mTarget; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -135,7 +138,7 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public TARGET setRequestMode(RequestEnum requestEnum) { |
|
|
|
public TARGET setRequestMode(RequestEnum requestEnum) { |
|
|
|
mTaskEntity.requestEnum = requestEnum; |
|
|
|
mTaskEntity.requestEnum = requestEnum; |
|
|
|
return (TARGET) this; |
|
|
|
return mTarget; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -145,12 +148,12 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public TARGET setHeaderMd5Key(String md5Key) { |
|
|
|
public TARGET setHeaderMd5Key(String md5Key) { |
|
|
|
if (TextUtils.isEmpty(md5Key)) return (TARGET) this; |
|
|
|
if (TextUtils.isEmpty(md5Key)) return mTarget; |
|
|
|
mTaskEntity.md5Key = md5Key; |
|
|
|
mTaskEntity.md5Key = md5Key; |
|
|
|
if (TextUtils.isEmpty(mTaskEntity.md5Key) || !mTaskEntity.md5Key.equals(md5Key)) { |
|
|
|
if (TextUtils.isEmpty(mTaskEntity.md5Key) || !mTaskEntity.md5Key.equals(md5Key)) { |
|
|
|
mTaskEntity.update(); |
|
|
|
mTaskEntity.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
return (TARGET) this; |
|
|
|
return mTarget; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -159,13 +162,13 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public TARGET setHeaderContentLengthKey(String contentLength) { |
|
|
|
public TARGET setHeaderContentLengthKey(String contentLength) { |
|
|
|
if (TextUtils.isEmpty(contentLength)) return (TARGET) this; |
|
|
|
if (TextUtils.isEmpty(contentLength)) return mTarget; |
|
|
|
mTaskEntity.contentLength = contentLength; |
|
|
|
mTaskEntity.contentLength = contentLength; |
|
|
|
if (TextUtils.isEmpty(mTaskEntity.contentLength) || !mTaskEntity.contentLength.equals( |
|
|
|
if (TextUtils.isEmpty(mTaskEntity.contentLength) || !mTaskEntity.contentLength.equals( |
|
|
|
contentLength)) { |
|
|
|
contentLength)) { |
|
|
|
mTaskEntity.update(); |
|
|
|
mTaskEntity.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
return (TARGET) this; |
|
|
|
return mTarget; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -175,13 +178,13 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public TARGET setHeaderDispositionKey(String dispositionKey) { |
|
|
|
public TARGET setHeaderDispositionKey(String dispositionKey) { |
|
|
|
if (TextUtils.isEmpty(dispositionKey)) return (TARGET) this; |
|
|
|
if (TextUtils.isEmpty(dispositionKey)) return mTarget; |
|
|
|
mTaskEntity.dispositionKey = dispositionKey; |
|
|
|
mTaskEntity.dispositionKey = dispositionKey; |
|
|
|
if (TextUtils.isEmpty(mTaskEntity.dispositionKey) || !mTaskEntity.dispositionKey.equals( |
|
|
|
if (TextUtils.isEmpty(mTaskEntity.dispositionKey) || !mTaskEntity.dispositionKey.equals( |
|
|
|
dispositionKey)) { |
|
|
|
dispositionKey)) { |
|
|
|
mTaskEntity.update(); |
|
|
|
mTaskEntity.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
return (TARGET) this; |
|
|
|
return mTarget; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -191,12 +194,12 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public TARGET setHeaderDispositionFileKey(String dispositionFileKey) { |
|
|
|
public TARGET setHeaderDispositionFileKey(String dispositionFileKey) { |
|
|
|
if (TextUtils.isEmpty(dispositionFileKey)) return (TARGET) this; |
|
|
|
if (TextUtils.isEmpty(dispositionFileKey)) return mTarget; |
|
|
|
mTaskEntity.dispositionFileKey = dispositionFileKey; |
|
|
|
mTaskEntity.dispositionFileKey = dispositionFileKey; |
|
|
|
if (TextUtils.isEmpty(mTaskEntity.dispositionFileKey) || !mTaskEntity.dispositionFileKey.equals( |
|
|
|
if (TextUtils.isEmpty(mTaskEntity.dispositionFileKey) || !mTaskEntity.dispositionFileKey.equals( |
|
|
|
dispositionFileKey)) { |
|
|
|
dispositionFileKey)) { |
|
|
|
mTaskEntity.update(); |
|
|
|
mTaskEntity.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
return (TARGET) this; |
|
|
|
return mTarget; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|