当前位置: 首页>>代码示例>>C#>>正文


C# HttpHeaders.set方法代码示例

本文整理汇总了C#中HttpHeaders.set方法的典型用法代码示例。如果您正苦于以下问题:C# HttpHeaders.set方法的具体用法?C# HttpHeaders.set怎么用?C# HttpHeaders.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpHeaders的用法示例。


在下文中一共展示了HttpHeaders.set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: downloadDspBill

		/// <summary>
		/// 下载
		/// </summary>
		/// <param name="configId">
		/// 
		/// @return </param>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @RequestMapping(value = "/download/{configId}", method = org.springframework.web.bind.annotation.RequestMethod.GET) public org.springframework.http.HttpEntity<byte[]> downloadDspBill(@PathVariable long configId)
		public virtual HttpEntity<sbyte[]> downloadDspBill(long configId)
		{

			// 业务校验
			configValidator.valideConfigExist(configId);

			ConfListVo config = configMgr.getConfVo(configId);

			HttpHeaders header = new HttpHeaders();
			sbyte[] res = config.Value.GetBytes();
			if (res == null)
			{
				throw new DocumentNotFoundException(config.Key);
			}

			string name = null;

			try
			{
				name = URLEncoder.encode(config.Key, "UTF-8");
			}
			catch (UnsupportedEncodingException e)
			{
				Console.WriteLine(e.ToString());
				Console.Write(e.StackTrace);
			}

			header.set("Content-Disposition", "attachment; filename=" + name);
			header.ContentLength = res.Length;
			return new HttpEntity<sbyte[]>(res, header);
		}
开发者ID:,项目名称:,代码行数:39,代码来源:

示例2: download2

		/// <summary>
		/// 批量下载配置文件
		/// </summary>
		/// <param name="confListForm">
		/// 
		/// @return </param>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @RequestMapping(value = "/downloadfilebatch", method = org.springframework.web.bind.annotation.RequestMethod.GET) public org.springframework.http.HttpEntity<byte[]> download2(@Valid com.baidu.disconf.web.service.config.form.ConfListForm confListForm)
		public virtual HttpEntity<sbyte[]> download2(ConfListForm confListForm)
		{

			LOG.info(confListForm.ToString());

			//
			// get files
			//
			IList<File> fileList = configMgr.getDisconfFileList(confListForm);

			//
			// prefix
			//
			string prefixString = "APP" + confListForm.AppId + "_" + "ENV" + confListForm.EnvId + "_" + "VERSION" + confListForm.Version;

			HttpHeaders header = new HttpHeaders();

			string targetFileString = "";
			File targetFile = null;
			sbyte[] res = null;
			try
			{
				targetFileString = TarUtils.tarFiles("tmp", prefixString, fileList);
				targetFile = new File(targetFileString);
				res = IOUtils.toByteArray(new System.IO.FileStream(targetFile, System.IO.FileMode.Open, System.IO.FileAccess.Read));
			}
			catch (Exception)
			{
				throw new DocumentNotFoundException("");
			}

			header.set("Content-Disposition", "attachment; filename=" + targetFile.Name);
			header.ContentLength = res.Length;
			return new HttpEntity<sbyte[]>(res, header);
		}
开发者ID:,项目名称:,代码行数:43,代码来源:


注:本文中的HttpHeaders.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。