Package com.pugh.sockso.web

Examples of com.pugh.sockso.web.Response


     */
   
    public void handleRequest() throws IOException, BadRequestException, SQLException {

        final Request req = getRequest();
        final Response res = getResponse();
        final String type = req.getUrlParam( 1 );

        res.setCookiesEnabled( false );

        serveFile();

    }
View Full Code Here


    protected void playTrack( final Track track, final MusicStream stream ) throws SQLException, IOException, BadRequestException {

        logTrackPlayed( track );

        final Response response = getResponse();
        stream.setHeaders( response );
        response.sendHeaders();
        stream.sendAudioStream( new DataOutputStream(response.getOutputStream()) );
           
    }
View Full Code Here

     *
     */
   
    private void sendHeaders() {

        final Response res = getResponse();
        final String filename = "playlist." +extension;
       
        res.addHeader( "Content-type", Files.getMimeType(filename) );
        res.addHeader( "Content-Disposition", "inline; filename=\"" +filename+ "\"" );
        res.addHeader( "Expires", "0" );
        res.addHeader( "Cache-Control", "must-revalidate, post-check=0, pre-check=0" );
        res.addHeader( "Pragma", "nocache" );

    }
View Full Code Here

     */
   
    public void handleRequest() throws SQLException, IOException, BadRequestException {

        final Request req = getRequest();
        final Response res = getResponse();
        final Locale locale = getLocale();
        final Properties p = getProperties();

        if ( p.get(Constants.WWW_DOWNLOADS_DISABLE).equals(Properties.YES) )
            throw new BadRequestException( locale.getString("www.error.downloadsDisabled"), 403 );
       
        final Database db = getDatabase();
        final String[] args = req.getPlayParams( false );
        final List<Track> tracks = Track.getTracksFromPlayArgs( db, args );
        final String fileName = getFileName( tracks );

        res.addHeader( "Content-length", Long.toString(getContentLength(tracks)) );
        res.addHeader( "Content-type", "application/zip" );
        res.addHeader( "Content-Disposition", "inline; filename=\"" + fileName + "\"" );
        res.sendHeaders();
        ZipOutputStream zip = null;
       
        try {
           
            zip = new ZipOutputStream( res.getOutputStream() );

            for ( final Track track : tracks )
                addTrackToZip( zip, track );

        }
View Full Code Here

     */
   
    protected void showBurp() throws IOException, SQLException {
       
        final Request req = getRequest();
        final Response res = getResponse();

        final TBurp tpl = new TBurp();
        tpl.setHost( req.getHeader("Host") );
        tpl.setReferer( req.getHeader("Referer") );
        tpl.setException( e );
        tpl.setMessage( e.getMessage() );
        tpl.setShowStackTrace( showStackTrace );
        tpl.setStatusCode( e.getStatusCode() );
       
        res.setStatus( e.getStatusCode() );
        res.showHtml( tpl );

    }
View Full Code Here

        };
    }

    public void testSetHeaders() {

        final Response res = createMock( Response.class );

        res.addHeader( matches("Content-Type"), (String) anyObject() );
        res.addHeader( matches("Content-Disposition"), (String) anyObject() );

        replay( res );

        ms.setHeaders( res );
View Full Code Here

    public void testLogout() throws IOException {
       
        Database db = createMock( Database.class );
        Request req = new TestRequest( "/" );
        Response res = createMock( Response.class );
        Locale locale = createNiceMock( Locale.class );

        Userer u = new Userer();
        u.setRequest( req );
        u.setResponse( res );
        u.setLocale( locale );
        u.setProperties( new StringProperties() );

        res.addCookie( (HttpResponseCookie) anyObject() );
        res.addCookie( (HttpResponseCookie) anyObject() );
        res.redirect( "/" );
        replay( res );
       
        u.logout();
       
        verify( res );
View Full Code Here

       
    }
    public void testRequireLoginNoRedirect() throws IOException {
       
        final Response res = createMock( Response.class );
        replay( res );
       
        final Userer u = new Userer();
       
        u.setUser( new User(1,"foo") );
View Full Code Here

       
    }
   
    public void testRequireLoginWithRedirect() throws IOException {
       
        final Response res = createMock( Response.class );
        res.redirect( "/user/login" );
        replay( res );
       
        final Userer u = new Userer();
       
        u.setUser( null );
View Full Code Here

TOP

Related Classes of com.pugh.sockso.web.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.