本文整理匯總了Java中net.sourceforge.subsonic.util.StringUtil.parseRange方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtil.parseRange方法的具體用法?Java StringUtil.parseRange怎麽用?Java StringUtil.parseRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.sourceforge.subsonic.util.StringUtil
的用法示例。
在下文中一共展示了StringUtil.parseRange方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRange
import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
private LongRange getRange(HttpServletRequest request, MediaFile file) {
// First, look for "Range" HTTP header.
LongRange range = StringUtil.parseRange(request.getHeader("Range"));
if (range != null) {
return range;
}
// Second, look for "offsetSeconds" request parameter.
String offsetSeconds = request.getParameter("offsetSeconds");
range = parseAndConvertOffsetSeconds(offsetSeconds, file);
if (range != null) {
return range;
}
return null;
}
示例2: handleRequest
import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
TransferStatus status = null;
try {
status = statusService.createDownloadStatus(playerService.getPlayer(request, response, false, false));
MediaFile mediaFile = getMediaFile(request);
Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist");
String playerId = request.getParameter("player");
int[] indexes = request.getParameter("i") == null ? null : ServletRequestUtils.getIntParameters(request, "i");
if (mediaFile != null) {
response.setIntHeader("ETag", mediaFile.getId());
response.setHeader("Accept-Ranges", "bytes");
}
LongRange range = StringUtil.parseRange(request.getHeader("Range"));
if (range != null) {
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
LOG.info("Got range: " + range);
}
if (mediaFile != null) {
if (mediaFile.isFile()) {
downloadFile(response, status, mediaFile.getFile(), range);
} else {
List<MediaFile> children = mediaFileService.getChildrenOf(mediaFile, true, true, true);
String zipFileName = FilenameUtils.getBaseName(mediaFile.getPath()) + ".zip";
downloadFiles(response, status, children, indexes, range, zipFileName);
}
} else if (playlistId != null) {
List<MediaFile> songs = playlistService.getFilesInPlaylist(playlistId);
Playlist playlist = playlistService.getPlaylist(playlistId);
downloadFiles(response, status, songs, null, range, playlist.getName() + ".zip");
} else if (playerId != null) {
Player player = playerService.getPlayerById(playerId);
PlayQueue playQueue = player.getPlayQueue();
playQueue.setName("Playlist");
downloadFiles(response, status, playQueue.getFiles(), indexes, range, "download.zip");
}
} finally {
if (status != null) {
statusService.removeDownloadStatus(status);
User user = securityService.getCurrentUser(request);
securityService.updateUserByteCounts(user, 0L, status.getBytesTransfered(), 0L);
}
}
return null;
}