<commit_before>package org.intermine.web.logic.export;

/*
 * Copyright (C) 2002-2008 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import javax.servlet.http.HttpServletResponse;


/**
 * Response util that sets content type and header for various formats.
 * @author <NAME>
 **/
public class ResponseUtil
{

    /**
     * Sets response header and content type for excel output.
     * @param response response
     * @param fileName file name of downloaded file
     */
    public static void setExcelHeader(HttpServletResponse response, String fileName) {
        response.setContentType("Application/vnd.ms-excel");
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Content-Disposition", 
                "attachment; filename=\"" + fileName + "\"");        
    }

    /**
     * Sets response header and content type for tab separated 
     * values output.
     * @param response response
     * @param fileName file name of downloaded file
     */
    public static void setTabHeader(HttpServletResponse response, String fileName) {
        response.setContentType("text/tab-separated-values");
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Content-Disposition", "inline; filename=\"" + fileName + "\"");
    }
    
    /**
     * Sets response header and content type for comma separated
     * values output.
     * @param response response
     * @param fileName file name of downloaded file
     */
    public static void setCSVHeader(HttpServletResponse response, String fileName) {
        response.setContentType("text/comma-separated-values");
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Content-Disposition", "inline; filename=\"" + fileName + "\"");
    }

    /**
     * Sets response header and content type for plain text output.
     * @param response response
     * @param fileName file name of downloaded file
     */
    public static void setPlainTextHeader(HttpServletResponse response, String fileName) {
        response.setContentType("text/plain");
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Content-Disposition ",
                           "inline; filename=\"" + fileName + "\"");        
    }
}<commit_msg>Fixed bug with direct opening of downloaded bulk file in IE. Refs #1269. <commit_after>package org.intermine.web.logic.export;

/*
 * Copyright (C) 2002-2008 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import javax.servlet.http.HttpServletResponse;


/**
 * Response util that sets content type and header for various formats.
 * @author <NAME>
 **/
public class ResponseUtil
{

    /**
     * Sets response header and content type for excel output.
     * @param response response
     * @param fileName file name of downloaded file
     */
    public static void setExcelHeader(HttpServletResponse response, String fileName) {
        setNoCache(response);
        response.setContentType("Application/vnd.ms-excel");
        response.setHeader("Content-Disposition", 
                "attachment; filename=\"" + fileName + "\"");
    }

    /**
     * Sets response header and content type for tab separated 
     * values output.
     * @param response response
     * @param fileName file name of downloaded file
     */
    public static void setTabHeader(HttpServletResponse response, String fileName) {
        setNoCache(response);
        response.setContentType("text/tab-separated-values");
        response.setHeader("Content-Disposition", "inline; filename=\"" + fileName + "\"");
    }
    
    /**
     * Sets response header and content type for comma separated
     * values output.
     * @param response response
     * @param fileName file name of downloaded file
     */
    public static void setCSVHeader(HttpServletResponse response, String fileName) {
        setNoCache(response);
        response.setContentType("text/comma-separated-values");
        response.setHeader("Content-Disposition", "inline; filename=\"" + fileName + "\"");
    }

    /**
     * Sets response header and content type for plain text output.
     * @param response response
     * @param fileName file name of downloaded file
     */
    public static void setPlainTextHeader(HttpServletResponse response, String fileName) {
        setNoCache(response);
        response.setContentType("text/plain");
        response.setHeader("Content-Disposition ",
                           "inline; filename=\"" + fileName + "\"");        
    }
    
    /**
     * Sets that the result must not be cached. Old implementation was set
     * Cache-Control to no-cache,no-store,max-age=0. But this caused problems 
     * in IE. File couldn't be opened directly.   
     * @param response response
     */
    public static void setNoCache(HttpServletResponse response) {
        // http://www.phord.com/experiment/cache/
        // http://support.microsoft.com/kb/243717
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "must-revalidate, max-age=0");
    }
}
{'fraction_non_alphanumeric': 0.10625566636446056, 'fraction_numerical': 0.005077062556663644, 'mean_word_length': 2.8093922651933703, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4628507', 'n_tokens_mistral': 1448, 'n_tokens_neox': 1419, 'n_words': 440}