當前位置: 首頁>>代碼示例>>Java>>正文


Java Response.getHeader方法代碼示例

本文整理匯總了Java中com.jayway.restassured.response.Response.getHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java Response.getHeader方法的具體用法?Java Response.getHeader怎麽用?Java Response.getHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jayway.restassured.response.Response的用法示例。


在下文中一共展示了Response.getHeader方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import com.jayway.restassured.response.Response; //導入方法依賴的package包/類
public ObjectNode create(RequestSpecification request)
{
	final String resolvedPath = getResolvedPath();
	Response response = request.post(resolvedPath);
	String location = response.getHeader("Location");
	Assert.assertNotNull(location, "Location on create request to " + resolvedPath + " is null");
	ObjectNode object = object(successfulRequest().get(location));
	final ID id = getId(object);
	cleanUpController.addCleanup(new StandardCleanupAfter(id));
	return object;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:12,代碼來源:AbstractCleanupRequests.java

示例2: uploadLarge

import com.jayway.restassured.response.Response; //導入方法依賴的package包/類
@Test(groups = "eps")
public void uploadLarge() throws IOException, DateParseException
{
	String stagingUrl = staging.create();

	File largeFile = File.createTempFile("large", "file");
	BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(largeFile));
	Random random = new Random();
	for( int i = 0; i < LARGE_FILE_SIZE; i++ )
	{
		out.write(random.nextInt());
	}
	out.close();
	largeFile.deleteOnExit();

	String uploadId = staging.startMultipart(stagingUrl, LARGE_PATH);
	long offset = 0;
	long length = largeFile.length();
	int partNum = 1;
	List<Integer> partNums = Lists.newArrayList();
	List<String> etags = Lists.newArrayList();
	while( offset < length )
	{
		long left = length - offset;
		long size = Math.min(left, MIN_PART_SIZE);
		partNums.add(partNum);
		etags.add(staging.uploadPart(stagingUrl, LARGE_PATH, uploadId, largeFile, partNum++, offset, size));
		offset += size;
	}
	String etag = staging.completeMultipart(stagingUrl, LARGE_PATH, uploadId, partNums, etags);
	Response response = staging.head(stagingUrl, LARGE_PATH);
	String lenHeader = response.getHeader("Content-Length");
	assertEquals(Long.parseLong(lenHeader), largeFile.length());
	assertEquals(response.getHeader("E-Tag"), etag);
	File downloadFile = File.createTempFile("large", "file");
	staging.downloadToFile(stagingUrl, LARGE_PATH, downloadFile);
	assertEquals(Files.hash(downloadFile, Hashing.md5()), Files.hash(largeFile, Hashing.md5()));
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:39,代碼來源:StagingApiTest.java


注:本文中的com.jayway.restassured.response.Response.getHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。