浏览代码

ensure we only send one content-type and content-length header

tags/2.0.1
Jonathan Cobb 4 年前
父节点
当前提交
813d84a9fb
共有 1 个文件被更改,包括 11 次插入1 次删除
  1. +11
    -1
      wizard-server/src/main/java/org/cobbzilla/wizard/resources/ResourceUtil.java

+ 11
- 1
wizard-server/src/main/java/org/cobbzilla/wizard/resources/ResourceUtil.java 查看文件

@@ -70,7 +70,17 @@ public class ResourceUtil {
if (contentLength != null) builder = builder.header(CONTENT_LENGTH, contentLength);
if (headers != null) {
for (NameAndValue h : headers) {
builder = builder.header(h.getName(), h.getValue());
if (h.getName().equalsIgnoreCase(CONTENT_TYPE) && contentType != null) {
// we already added a Content-Type header, don't add a second one
if (log.isDebugEnabled()) log.debug("send: already added "+CONTENT_TYPE+" ("+contentType+"), not adding "+CONTENT_TYPE+" from headers: "+h.getValue());

} else if (h.getName().equalsIgnoreCase(CONTENT_LENGTH) && contentLength != null) {
// we already added a Content-Length header, don't add a second one
if (log.isDebugEnabled()) log.debug("send: already added "+CONTENT_LENGTH+" header ("+contentLength+"), not adding "+CONTENT_LENGTH+" from headers: "+h.getValue());

} else {
builder = builder.header(h.getName(), h.getValue());
}
}
}
return builder.build();


正在加载...
取消
保存