Skip to content

Commit

Permalink
Revert "[#1839]add ContentType return while getConfig"
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun authored Jul 31, 2020
1 parent 43f6065 commit 77db5ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ private MediaType() {

public static final String TEXT_HTML = "text/html";

public static final String TEXT_PLAIN = "text/plain";
public static final String TEXT_PLAIN = "text/xml";

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

package com.alibaba.nacos.config.server.controller;

import com.alibaba.nacos.common.constant.HttpHeaderConsts;
import com.alibaba.nacos.config.server.constant.Constants;
import com.alibaba.nacos.config.server.enums.FileTypeEnum;
import com.alibaba.nacos.config.server.model.CacheItem;
import com.alibaba.nacos.config.server.model.ConfigInfoBase;
import com.alibaba.nacos.config.server.service.ConfigCacheService;
Expand Down Expand Up @@ -138,18 +136,8 @@ public String doGetConfig(HttpServletRequest request, HttpServletResponse respon
isBeta = true;
}
}

final String configType =
(null != cacheItem.getType()) ? cacheItem.getType() : FileTypeEnum.TEXT.getFileType();
response.setHeader("Config-Type", configType);

String contentTypeHeader;
try {
contentTypeHeader = FileTypeEnum.valueOf(configType.toUpperCase()).getContentType();
} catch (IllegalArgumentException ex) {
contentTypeHeader = FileTypeEnum.TEXT.getContentType();
}
response.setHeader(HttpHeaderConsts.CONTENT_TYPE, contentTypeHeader);
String configType = cacheItem.getType();
response.setHeader("Config-Type", (null != configType) ? configType : "text");
}
File file = null;
ConfigInfoBase configInfoBase = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.alibaba.nacos.config.server.enums;

import com.alibaba.nacos.common.http.param.MediaType;

/**
* Config file type enum.
*
Expand All @@ -29,73 +27,58 @@ public enum FileTypeEnum {
/**
* Yaml file.
*/
YML("yaml", MediaType.TEXT_PLAIN),
YML("yaml"),

/**
* Yaml file.
*/
YAML("yaml", MediaType.TEXT_PLAIN),
YAML("yaml"),

/**
* Text file.
*/
TXT("text", MediaType.TEXT_PLAIN),
TXT("text"),

/**
* Text file.
*/
TEXT("text", MediaType.TEXT_PLAIN),
TEXT("text"),

/**
* Json file.
*/
JSON("json", MediaType.APPLICATION_JSON),
JSON("json"),

/**
* Xml file.
*/
XML("xml", MediaType.APPLICATION_XML),
XML("xml"),

/**
* Html file.
*/
HTM("html", MediaType.TEXT_HTML),
HTM("html"),

/**
* Html file.
*/
HTML("html", MediaType.TEXT_HTML),
HTML("html"),

/**
* Properties file.
*/
PROPERTIES("properties", MediaType.TEXT_PLAIN);
PROPERTIES("properties");

/**
* File type corresponding to file extension.
*/
private String fileType;

/**
* Http Content type corresponding to file extension.
*/
private String contentType;

FileTypeEnum(String fileType) {
this.fileType = fileType;
this.contentType = MediaType.TEXT_PLAIN;
}

FileTypeEnum(String fileType, String contentType) {
this.fileType = fileType;
this.contentType = contentType;
}

public String getFileType() {
return this.fileType;
}

public String getContentType() {
return contentType;
}
}

0 comments on commit 77db5ba

Please sign in to comment.