<commit_before>/**/

try {
	def parms = request.getParameterMap().collectEntries{k,v-> [k,v[0]]}
	assert Props.require("repository.root")
	File repoRoot = new File( Props."repository.root" )
	def path = request.getPathInfo()
	
	if(path){
		File repoPath = new File(repoRoot, path)
		if( repoPath.exists() ){
			if(repoPath.isDirectory()){
				if(path.endsWith("/")){
					def listFiles = repoPath.listFiles().sort{ a,b-> a.isFile() <=> b.isFile() ?: a.getName() <=> b.getName() }
					response.setStatus(200)
					response.setContentType("text/html")
					
					html.html{
						head{
							title("rest-ivy:${path}")
						}
						body{
							h2("rest-ivy:${path}")
							ul{
								if( path!="/" ){
									li{
										a(href:"..", ".." )
									}
								}
								
								listFiles.each{ File file ->
									li{
										def name = file.getName() + (file.isDirectory() ?"/":"")
										a( href:name, name )
									}
								}
							}
						}
					}
				}else{
					response.setStatus(response.SC_MOVED_TEMPORARILY);
					response.setHeader("Location", ".${path}/");
				}
			}else{
				response.setStatus(200)
				response.setContentType( URLConnection.guessContentTypeFromName(repoPath.getName()) ?: "application/octet-stream" )
				response.setContentLength( (int)repoPath.length() ) //TODO:int???
				//response.setHeader("Content-Disposition", "attachment; filename=\"" + repoPath.getName() + "\"");
				response.setHeader("x-file-name", repoPath.getName());
				response.setHeader("x-last-modified", new java.sql.Timestamp( repoPath.lastModified() ).toString());
				response.setHeader("Last-Modified", Dates.httpFormat( repoPath.lastModified() ) );
				
				//write content into output stream
				def stream = response.getOutputStream()
				stream << repoPath.newInputStream()
				stream.flush()
				stream.close()
			}
			
		}else{
			response.setStatus(404,"ERROR: not found")<commit_msg>support HEAD request limit to GET format file listing with doublequotes <a href="..">... so /repository  can be used by ivy as resolver-url<commit_after>/**/

try {
	def parms = request.getParameterMap().collectEntries{k,v-> [k,v[0]]}
	assert Props.require("repository.root")
	File repoRoot = new File( Props."repository.root" )
	def path = request.getPathInfo()
	def method = request.getMethod()
	
	if(path){
		File repoPath = new File(repoRoot, path)
		if( repoPath.exists() ){
			if(repoPath.isDirectory()){
				if(path.endsWith("/")){
					assert method in ['GET','HEAD']
					def listFiles = repoPath.listFiles().sort{ a,b-> a.isFile() <=> b.isFile() ?: a.getName() <=> b.getName() }
					response.setStatus(200)
					response.setContentType("text/html")
					if(method=='GET'){
						html.setDoubleQuotes(true)
						html.html{
							head{
								title("rest-ivy:${path}")
							}
							body{
								h2("rest-ivy:${path}")
								ul{
									if( path!="/" ){
										li{
											a(href:"..", ".." )
										}
									}
									
									listFiles.each{ File file ->
										li{
											def name = file.getName() + (file.isDirectory() ?"/":"")
											a( href:name, name )
										}
									}
								}
							}
						}
					}
				}else{
					response.setStatus(response.SC_MOVED_TEMPORARILY);
					response.setHeader("Location", ".${path}/");
				}
			}else{
				assert method in ['GET','HEAD']
				response.setStatus(200)
				response.setContentType( URLConnection.guessContentTypeFromName(repoPath.getName()) ?: "application/octet-stream" )
				response.setContentLength( (int)repoPath.length() ) //TODO:int???
				//response.setHeader("Content-Disposition", "attachment; filename=\"" + repoPath.getName() + "\"");
				response.setHeader("x-file-name", repoPath.getName());
				response.setHeader("x-last-modified", new java.sql.Timestamp( repoPath.lastModified() ).toString());
				response.setHeader("Last-Modified", Dates.httpFormat( repoPath.lastModified() ) );
				if(method=='GET'){
					//write content into output stream
					def stream = response.getOutputStream()
					stream << repoPath.newInputStream()
					stream.flush()
					stream.close()
				}
			}
			
		}else{
			response.setStatus(404,"ERROR: not found")
{'fraction_non_alphanumeric': 0.1736111111111111, 'fraction_numerical': 0.005268199233716475, 'mean_word_length': 2.7062999112688555, 'pattern_counts': {'":': 2, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '906984', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1326, 'n_words': 232}