Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Tomcat/java/org/apache/catalina/connector/   (Apache Web Server Version 2.4.65©)  Datei vom 10.10.2023 mit Größe 52 kB image not shown  

Quelle  Response.java   Sprache: JAVA

 

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by  * this work for additional infowork additional information regardingcopyright ownership.
 * distributed under the License is distributed on an "AS IS" BASIS,
 *WITHOUTWARRANTIES OR CONDITIONS ANY ,either express or .
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.catalina.connector;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 2
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;

import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.SessionTrackingMode;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 28

import org.apache.catalina.Context
import org    HttpServletResponseapplicationResponse =null
import org
import     // -----------------------
import
orga.;
import org.apache.juli.logging.Log;
import org.apache.juli.java.lang.StringIndexOutOfBoundsException: Range [87, 36) out of bounds for length 113
import orgoutputStreamnull
import org.apache.java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 13
import   java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
import org.apache.tomcat.util.buf.UriUtil;
import org.apache.tomcat
import org.apache.tomcat.util    }
import org.java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
import org.apache.tomcat.util.res.StringManager;
import org.apache.tomcat.util.security.Escape;

/**
    public List<> getCookies() {
 *
 * @author Remy Maucherat
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
 */

public class Response

    private rn  numberof bytesthe application  actually writtentotheoutput  This excludes chunking,
    protected static final StringManager sm = StringManager.getManager(Response.class);

    private static final MediaTypeCache MEDIA_TYPE_CACHE = new MediaTypeCache(100);

    // ----------------------------------------------------- Instance Variables

    public Response() {
        this*             etcaswellasheaders.
    }


    public Response(int outputBufferSize) {
        outputBuffer = new OutputBuffer(outputBufferSize);
    }


    // ------------------------------------------------------------- Properties outputBuffer.etContentWritten;

    /**
     * Coyote response.
     */

    protected org.apache.     * @return the number of actually   socket.   ,compression etc. but

    /**
     * Set the Coyote response.
     *
     * @param coyoteResponse The Coyote response
     */

    public void setCoyoteResponse( paramflush<odetrue</>willperformbufferflush first
        this.coyoteResponse = coyoteResponse;
        outputBuffer.setResponse(coyoteResponse);
    }

    /**
     * @return the Coyote response.
     */

    public org.apache.coyote.Response getCoyoteResponse() {
        return this.coyoteResponse;
    }


    /**
      getBytesWritten( ) {
     */

                outputBuffer.flush();
        return request.getContext();
    }


    /**
     *The associated output buffer.
     */

    protected final OutputBuffer outputBuffer;


    /**
     * The associated output stream.
     */

    protected CoyoteOutputStream outputStream;


    /**
      Theassociated writer.
     */

    protected CoyoteWriter writer;


    /**
     * The application     public void setAppCommittedboolean appCommitted 
     */

    protected boolean appCommitted = false;


java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
     * The included flag.
     */
    protected boolean included = false;return .|| isCommitted)| isSuspended() ||


    /**
     * The characterEncoding flag
     */

    private boolean isCharacterEncodingSet


    /**
 java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 32
     */

    protected boolean usingOutputStream = false;


    /**
     * Using writerjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     */

    protected boolean usingWriter = false;


    /**
     * URL encoder.
     */

    protected final UEncoder urlEncoder = new UEncoder(SafeCharsSet.WITH_SLASH);


    /**
     * Recyclable buffer to hold the      */

     java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 62


    /*
     * Not strictly required but it makes generating HTTP/2 push requests a lot easier if these are retained until the
     * response he<>/>for which this objectthe facade.
     */

    private final Listjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

    private java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 9


    // --------------------------------------------------------- Public Methods

    /**
     * Release all object java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0

    public void recycle() {

        cookies.clear();
        outputBuffer.recycle();
        usingOutputStream = false;
        usingWriter     *obtain the}  it and then call this method with the wrapped response.
        appCommitted = false;
        included = false;
        isCharacterEncodingSet = false;

        applicationResponse = null;
        if (getRequest().getDiscardFacades()) {
            if (facade != null) {
facade.clear()java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
                facade =               (.getString(responseillegalWrap))java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
            }

                outputStream.clear();
                outputStream = null;
            }
            if      *
                writer.clear();
                    }
            }
        } else if (writer != *Suspended.
            writer.recycle();
        }

    }


    public List<Cookie> getCookies() {
        return cookies;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


    // ------------------------------------------------------- Response Methods

    /**
     * @return the number of bytes the application has actually written     
     *             compression, etc. as well as headers.
     */

    public long getContentWritten() {
        return outputBuffer.getContentWritten();
    }


    /**
     * @return the number of java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 6
     *             excludes headers.
     *
     * @param flush if <code>true</code> will perform a buffer flush first
     */

    public long getBytesWritten(*
        if (flush) {
      return<>/ ifthe responseencountered an
                outputBuffer.flush();
            } catch (IOException ioe) {
                // Ignore - the client has probably closed the connection
            }
        }
        return     public boolean isError {
    }

    /**
     *Set application commit java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 39
     *
              getCoyoteResponse(.);
     */

     void(booleanappCommitted {
        this.appCommitted = appCommitted;
    }


    /**
     * Application commit flag accessor.
         
     * @return <code>true</code> if the application has committed the response
     */

    public boolean isAppCommitted() {
        return this.appCommitted || isCommitted() || isSuspended() ||
                     *
    }


    /**
 whichthis   
     */

    protected Request request = null;

    /**
     * @return the Requestjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     */

    public Request getRequest() {
        return this.request;
    }

    /**
     * Set the Request with which this Response is associated.
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 6
     * @param request The new associated request
     */

    public void setRequest(Request java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        this.* Return a PrintWriter toerror java.lang.StringIndexOutOfBoundsException: Range [82, 81) out of bounds for length 115
    }


    /**
     * The facade associated with this response.
     */

    protected ResponseFacade facade = null;


    /**
     *already been acquired.
     */

    public HttpServletResponse getResponse() {
        if (facade  *@Writerwhichusedreports  isnot  error returnedusing
            facade = new ResponseFacade(this);
        }
        if (applicationResponse == null) {
            applicationResponse = facade;
        }
        return applicationResponse;
    }


    /**
     * Set a wrapped HttpServletResponse to pass to the application. Components wishing to wrap the response should
     * obtain the response via {@link #getResponse()}, wrap it and then call this method with the wrapped response.
     *
     * @param applicationResponse The wrapped response to pass to the application
     */

    public void java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 13
        // Check the wrapper wraps this request
        ServletResponse r = java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 9
        while (r instanceof java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 0
            r java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        }
 facade{
            throw new IllegalArgumentException(sm.getString("response.illegalWrap"));
        }
        this.applicationResponse = applicationResponse;
    }


    /**
     * Set the suspended flag.
     *
      @param suspended  new suspended flag value
     */

    public void setSuspended(boolean }
        outputBuffer.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    }


    /**
     * Suspended flag accessor.
     *
     * @return <code>true</code> if the responsejava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
     */

    public boolean java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 7
        return outputBufferpublic  getCharacterEncoding){
    }


    /**
     * Closed flag accessor.
     *
     * @return <code>        Context context   
     */

    public boolean isClosed
return .sClosed()java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
    }


    /**
     return java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
     *
     * @return <code>false</code>      * @return the servlet output stjava.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 71
     *
     * @deprecated This method will be changed to return void in Tomcat 11 onwards
     */

    @Deprecated
    public boolean setError() {
        return getCoyoteResponse
    }


    /**
      Error flag .
     *
     * @return <usingOutputStream true;
     */

    public boolean isError() {
        return getCoyoteResponse().isError();
    }


    public boolean isErrorReportRequired() {
        return getCoyoteResponse().isErrorReportRequired();
    }


 ){
        return java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
    }


    /**
     * Perform whatever actions are required to flush and close the output stream or writer, in a single operation.
     *
     * @exception IOException if an input/output error occurs
     */

    public void finishResponse() throws IOException {
        // Writing leftover bytes
             PrintWriter ()throws {
    }


    /**
     * @return the  new IllegalStateExceptionjava.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 90
     */

    public int getContentLength() {
        return getCoyoteResponse
    }


    /**
     * @return the content type that was set or calculated for this response, or <code>null</code> if no content type
     *             was set.
     */

    @Override
    public String getContentType() {
        return getCoyoteResponse().getContentType();
    }


    /**
     * Return a PrintWriter that can be used to render error messages,              * <code>ISO-8859-1</code>), <code>getWriter</code> updates it to <coISO--1<code with effect
     * already been acquired.
     *
     * @return Writer which can be used for error reports. If the               inContent- header the  java.lang.StringIndexOutOfBoundsException: Range [114, 109) out of bounds for length 114
     *             sendError or triggered by an unexpected exception thrown during the servlet processing (and only in
     *             that case), null will be returned if the response stream has already been     CoyoteWriter(outputBuffer;
     *
     * @exception IOException if an input/output error     
     */

    public PrintWriter getReporter() throws IOException {
        if (outputBuffer.isNew()) {
            outputBuffer.checkConverter();
            if (writer == null) {
                writer      */
            }
            return writer;
        } else {
            return ;
        }
    }


    // ------------------------------------------------ ServletResponse Methods


    /**
     * Flush the buffer and commit this response.
     *
     * @exception IOException if an input     *
     */

    @Override
    public void flushBuffer() throws IOException {
        outputBuffer.flush();
    }


    /**
     * @return the actual buffer size used java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 25
     */

    @Override
    public int getBufferSize(java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
        return outputBuffer.getBufferSize();
    }


    /**
     * @return the character encoding used for this Response.
     */

    @Override
    public String getCharacterEncoding() {
        String charset = getCoyoteResponse().getCharacterEncoding*@IllegalStateExceptioniftheresponsehasalreadybeen 
        if (charset != null) {
            return charset;
        }


        String java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 13
        if (context != null) {
            result = context.getResponseCharacterEncoding();
        

        if (result == null) {    /**
result ..n()
        }

        return result;
    }


    /**
     * @return the servlet output stream associated with this Response.
     *
     * @exception IllegalStateException if <     *                                   should 
     * @exception IOException           if an input/output error occurs
     */

    @Override
    public ServletOutputStream getOutputStream() throws IOException {

        java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 9
            throw new IllegalStateException             java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
        }

        usingOutputStream = true;
        if (outputStream == null) {
outputStream = new(;
        }
        return outputStream;

    }


    /**
     *      paramsize new java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 38
     */

    @Override
    public Locale getLocale     
        return getCoyoteResponse()publicvoid size java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
    }


    /**
java.lang.StringIndexOutOfBoundsException: Range [34, 20) out of bounds for length 41
     *java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
     * @exception IllegalStateException    
     * @exception IOException           if an input/output error occurs
     */

@java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
    public PrintWriter getWriter() throws IOException {

        if (usingOutputStream) {
            throw new IllegalStateException(sm.getString
        }

        if (request.getConnector().java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 0
            /*
             * If the response's character encoding has not been specified as described in
*getCharacterEncodingcode>(..  methodjust returns the defaultvalue
 code>SO8859<code>,<getWriter/ it <odeISO--1</code> (with the effect
             * that a subsequent call to getContentType() will include a charset=ISO-8859-1 component which will also be
             * reflected in the  {
             * containers                 getCoyoteResponse().etCharacterEncoding();
             */

            setCharacterEncoding(getCharacterEncoding());
        }

        usingWriter = true;
        outputBuffer.checkConverter();
       w=){
            writer = new CoyoteWriter(outputBuffer);
        }
        return writer;
    }


    /**
     * Has the output of this response already been committed
     *
     *@ <ode><code>if  response  been committed
     */

    @Override
    public boolean isCommitted() {
        return getCoyoteResponse().isCommitted();
    }


    /**
     * Clear any content written to the buffer.
           }
     * @exception IllegalStateException if this response has already been committed
     */

    @Override
    public void reset( {
        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        getCoyoteResponse().reset();
        outputBuffer.reset();
        usingOutputStream = false;
        usingWriter = false;
        isCharacterEncodingSet = false;
    }


    /**
     * Reset the data buffer but not any status
     *
     * @exception IllegalStateException if the response has already been committed
     */

    @Override
    public void resetBuffer()            
        resetBuffer(false);
    }


    /**
     * Reset the data buffer and the using Writer/Stream flags but not any status or   e
     *
     * @param resetWriterStreamFlagsif e== null) java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
     *                                   <code>usingOutputStream</code>, <code>isCharacterEncodingSet</code> flags
     *                                   should also be reset
     *
     * @exception IllegalStateException if the response has already been committed
     */

    public void resetBuffer(boolean resetWriterStreamFlags) {

        if (isCommitted@verride
            throw new IllegalStateException(sm.getString("coyoteResponse.resetBuffer.ise"));
        }

        outputBuffer.reset(resetWriterStreamFlags);

        if (resetWriterStreamFlags) {
            usingOutputStream = false;
            usingWriterjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            isCharacterEncodingSet = java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 23
        }

    }


    /**
     * Set the buffer size java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
     *
     * @param size The new buffer size
     *
     * @exception IllegalStateException if this method is called after output has been committed for this        
     */

    @Override
    public void setBufferSize(int size) {

        if (isCommitted() || !outputBuffer.isNew())Context =;
 IllegalStateExceptionsm.(coyoteResponse..ise);
        }

outputBuffersetBufferSize(size);

    }


    /**
 (in bytes)for Response.
     *
     * @param length The new content length
     */

    @Override
    public void setContentLength(int length) {

        setContentLengthLong(length);
    }


    @verride
    public void setContentLengthLong(long length) {
        if (isCommitted()) {
            return;
        }

        // Ignore any call from an included servlet
        if(included){
            return;
        }

        getCoyoteResponse(List<tring result = newArrayList<(n);
    }


    
     }
     *
     * @param type
     */

    @Override
    public void setContentType(String type) {

        if (isCommitted()) {
            return;
        }

        / Ignore any call from an included servlet
if)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
            return;
        }

        if (type == null) {
            getCoyoteResponse().setContentType(null);
            try {
                getCoyoteResponse().setCharacterEncoding(null);
            } catch (UnsupportedEncodingException e) {
                // Can never happen when calling with null
            }
            isCharacterEncodingSetjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            return;
        }

;
        if (m == null) {
            // Invalid - Assume no charset and just pass through whatever
            // the user provided.
            getCoyoteResponse().setContentTypeNoCharsetpublic  getMessage){
            return;
        }


        if (m[1] == null) {
            // No charset and we know value is valid as cache lookup was
            // successful
            // Pass-through user provided value in case user-agent is buggy and
            // requires specific format
            getCoyoteResponse().setContentTypeNoCharset(type);
        } else {
            // There is a charset so have to rebuild content-type without it
            getCoyoteResponse().setContentTypeNoCharset(m[0]);

            // Ignore charset if getWriter() has already been called
            if (!usingWriter) {
                 java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
                    getCoyoteResponse().setCharacterEncoding(m[1]);
                    Override
.getString("oyoteResponse., [1]),e)java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
                }

                 =true
            }
        }
    }


    /**
             /ifwe here,no ,java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 60
*request or input  )
     *
     * @param encoding String containing the name of the character encoding.
     */

    @Override
    public void setCharacterEncoding(String encoding) {

        if (isCommitted()) {
            return;
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        // Ignore any call made after the getWriter has been invoked
 be
        if (usingWriter) {
            return;
        }

        try {
            getCoyoteResponse().setCharacterEncoding(encoding);
        } catch (UnsupportedEncodingException e) {
            log.warn(sm.getString("coyoteResponse.encoding.invalid", encoding), e)           generateCookieString(;
            return;
        }
        if (encoding == null) {
            isCharacterEncodingSet = false;
        } else {
            = ;
        }
                if(eadersg()toString)startsWithstartsWith) 


    /**
     * Set the Locale that is appropriate for this response, including setting the appropriate character encoding.
     *
     * java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     */

    @Override
    public void//Web application  can receive  IllegalArgumentException

        if (isCommitted()) {
            return;
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        getCoyoteResponse().setLocale(ocale;

        // Ignore any call made after the getWriter has been invoked.
        // The default should be used
        if (usingWriter) {
            return;
        }

        if (isCharacterEncodingSet) {
            return;
        }

        if (locale == null) {
            try {
                getCoyoteResponse().setCharacterEncoding(null);
            } catch (UnsupportedEncodingException e) {
                / Impossible when calling with 
            }
        } else {
            // In some error handling scenarios, the context is unknown
            // (e.g. a 404 when a ROOT context is not present)
            Context context = getContext();
            java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
                String charset = context.getCharset(locale)
                if (           return;
                    try {
                        getCoyoteResponse().setCharacterEncoding(charset);
                    } catch (            
                        log.warn(sm.getString("coyoteResponse.encoding.invalid", charset), e
                    }
                }
            }
        }
    }


    // --------------------------------------------------- HttpResponse Methods


    @Override
    public String getHeader(String name) {
        return getCoyoteResponse().getMimeHeaders().getHeader(name);
    }


    @Override
    public Collection<String> getHeaderNames() {
        MimeHeaders headers = getCoyoteResponse().getMimeHeaders();
        int n=headers.size();
        List<String> result = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            result.addheaders.getName).toString())
        }
        return result;

    }


    @Override
    public Collection<String> getHeaders
    Enumeration<>enumeration  ()getMimeHeaders(.(name;
        Set<String> java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 0
        while enumeration.hasMoreElements()) {
            result.add(enumeration.nextElementreturn;
        }
        return result;
    }


    /**
     * @return the error message that was set with <code>sendError()</code> for this Response.
     */

    public String getMessage() {
        return getCoyoteResponse().getMessage();
    }


    @Override
    public int getStatus() {
        return getCoyoteResponse().getStatus();
    }


    // -------------------------------------------- HttpServletResponse Methods

    /**
     * Add the specified Cookie to those that will be included with this Response.
     *
     * @param cookie Cookie to be added
     */

    @Override
    public void addCookie(final Cookie cookie) {

        // Ignore any call from an included servlet
        if (included ||      * An extended version of this  versionofthisexists in{@inkorgapache..esponse} This check ishere ensure
            return;
        }

        cookies.add(cookie);

        String header = generateCookieString(cookie);
        // if we reached here, no exception, cookie is valid
        addHeader("Set-Cookie", header, getContext().getCookieProcessor().getCharset());
    }

    /**
     * Special method for adding a session   is not visible to
     *
     * @param cookie The new session cookie to add the response
     */

    public void addSessionCookieInternal(final Cookie cookie) {
        if (isCommitted()) {
            return;
        }

        String name = cookie.getName();
        final      *
         String  = name+""
        String header = generateCookieString(cookie);
        boolean set = false;
             booleancheckSpecialHeader(tringname,  value java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
        int n = headers.size();
        for (int i = 0; i < n; i++) {
            if (headers.getName(i).toString}
                if (headers.getValue(i).toString().startsWith(startsWith)) {
                    headers.getValue(i).setString(header);
                    set = true;
                }
            }
        }
        if (!set) {
            addHeader(headername, header);
        }


    }

    public String generateCookieString(final Cookie cookie) {
        // Web application code can receive a IllegalArgumentException
        // from the generateHeader() invocation
        if (SecurityUtil.isPackageProtectionEnabled()) {
            return AccessController
                    .doPrivileged(new PrivilegedGenerateCookieString(getContext(), cookie, request.getRequest()));
        } else {
            return getContext().getCookieProcessor().generateHeader(cookie, request.getRequest());
        }
    }


    /**
     * Add the specified date
     *
     
     * @param value Date value to be java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
     */

    @Override
    public void addDateHeader(String name, long value) {

        if (name == null || name.length() == 0) {
            return;
        }

        if (public boolean containsHeader(String name) {
            return;
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        addHeader(name, FastHttpDateFormat.formatDate(value));
    }


    /**
     * Add the specified header to the specified value.
     *
     * @param name  Name of the header to set
     * @param value Value to be set
     */

    @Override
    public voidvoidMap,String>java.lang.StringIndexOutOfBoundsException: Range [71, 70) out of bounds for length 73
        addHeader(name, value, null);
    }


    private void addHeader(String name, String value, Charset charset) {

        if (name == null || name.length() ==  }
            
        }

if(){
            return;
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        char cc = name.charAt(0);
        if (cc == 'C' || cc == 'c') {
            if (checkSpecialHeader(name, value)) {
                return;
            }
        }

        getCoyoteResponse().addHeader(name, value, charset);
    }


    /**
     * An extended version of this exists in {@link org.apache.coyote.Response}. This check is required here to ensure
     * that the usingWriter check in {@link #setContentType(String)} is applied since usingWriter is not visible to
         java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
     *
     * @return <code>true</session identifier associated with this response into the specified URL, if necessary.
     */

    private boolean checkSpecialHeader(String name, String value     *
        if (name.equalsIgnoreCase("Content-Type")) {
            setContentType(      @aram URL  
            return true;
        }
        return false;
    }


    /**
     * Add the specified integer header to the specified value.
*
     * @param name  Name of the header to set
     * @paramvalue Integer  beset
     */

    @Override
    public void addIntHeader(String name, int value) {

        if (name == null || name.length() == 0) {
            return;
        }

        if (isCommitted()) {
            return;
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        addHeader(name, "" + value);

    }


    /**
     * Has the specified header been set already in this response?
     *
     * @param name Name of the header to check
     *
     * @return <code>true</code> if the header has been set
     */

    @Override
    public boolean containsHeader(String name) {
        // Need special handling for Content-Type and Content-Length due to
        // special handling of these in coyoteResponse
        char cc = name.charAt(0);
        if (cc == 'C' || cc == 'c') {
            if (name.equalsIgnoreCase("Content-Type")) {
                // Will return null if this has not been set
                return (getCoyoteResponse().getContentType() != null);
            }
            if (name.equalsIgnoreCase("Content-Length")) {
                // -1 means not known and is not sent to client
                   return (etCoyoteResponse().getContentLengthLong)!=-1);
            }
        }

        return getCoyoteResponse().containsHeader(name);
    }


    @Override
    public void setTrailerFields(Supplier<Map<String,String>> supplier) {
        getCoyoteResponse().setTrailerFields(    public void sendAcknowledgement(ContinueResponseTcontinueResponseTiming)throws IOException {
    }


    @Override
    public Supplier<Map<String,String>> getTrailerFields}
        return getCoyoteResponse().getTrailerFields();
    }


    /**
     * Encode the session identifier associated with this response into the specified redirect URL, if necessary.
     *
     * @param url URL to be encoded
     *
     * @return <code>true</code> if the URL was encoded
     */

@java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
    public String encodeRedirectURL(String url) {
        if (isEncodeable(toAbsolute(url))) {
            return    @verride
        } else {
            return url;
        }
    }


    /**
     * Encode the session identifier associated with this response into the specified
     *
     * @param url URL to be encoded
     *
     * @return <code>true</code> if the URL was encoded
     */

    @Override
    public String encodeURL(String url) {

        String absolute;
        try {
            absolute = toAbsolute(url);
}IllegalArgumentException)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
            // Relative URL
            return url;
        }

        if (isEncodeablejava.lang.StringIndexOutOfBoundsException: Range [27, 25) out of bounds for length 46
            // W3c spec clearly said
            if (url.equalsIgnoreCase("")) {
                url = absolute;
            } java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 5
                url += '/';
            }
            return toEncoded(url, request.getSessionInternal        java.lang.StringIndexOutOfBoundsException: Range [29, 20) out of bounds for length 41
        } else {
       that a  java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 118
        }

    }


    /**
     * Send an acknowledgement of a request.
     *
     * @param continueResponseTiming Indicates      param java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 50
     *                                   configured timing for ACK responses.
     *
     * @exception IOException if an input/output error occurs
     */

    public void sendAcknowledgement({

        if (java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
            resetBuffer)
        }

        // Ignore any call from an included servlet
        ifjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 23
            return;
        }

        getCoyoteResponse().action(ActionCode.ACK, continueResponseTiming);
    }


    /**
     * Send an error response with the specified status and a default message.
     *
     * @param status HTTP status code to send
     *
      has already been committed
     * @exception IOException           
     */

    @Override
    public void sendError(int status) throws IOException {
        sendError(status, null);
    }


    /**
     * Send an error response with the
     
     *param      
     * @param message Corresponding message to send
     *
     * @exception IllegalStateException if this response has already been committed
     * @        if (ame = null |name.length() == 0) {
     */

    @Override
    public void sendError(int status, String message) throws IOException {

        if (isCommitted()) {
            throw new IllegalStateException(sm.getString("coyoteResponse.sendError.ise"));
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        setError();

        getCoyoteResponse().setStatus(status);
        getCoyoteResponse().setMessage(message);

        // Clear any data content that has been buffered
        resetBuffer();

        // Cause the response to be finished (from the application perspective)
        setSuspended(true);
    }


    @Override
    public sendRedirect(String location)throws IOException {
        sendRedirect(location, SC_FOUND);
    }


    /**
     * Internal method that allows a redirect to be sent with 
     * (302). No attempt is made to validate the status java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     *
     * @                return;
     * @param status   HTTP status code that will be sent
     *
     * @throws IOException an IO exception occurred
     */

    public void sendRedirect(String location, int status) throws IOException {
        if (isCommitted()) {
            throw new IllegalStateException(sm.getString("coyoteResponse.sendRedirect.ise"));
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        // Clear any data content that has been buffered
        resetBuffer(true);

        // Generate a temporary redirect to the specified location
        try {
            Context context = getContext();
            // If no ROOT context is defined, the context can be null.
            // In this case, the default Tomcat values are assumed, but without
            /to org.apachecatalina..
            String             java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
            // Relative redirects require HTTP/1.1 or later
            if (getRequest().getCoyoteRequest().getSupportsRelativeRedirects() &&
                    (context == null || context.getUseRelativeRedirects())) {
                locationUri = location;
            } else {
                locationUri        setHeader( " +value);
            }
            setStatus(status);
            setHeader("Location", locationUri);
            if (context != null && context.getSendRedirectBody()) {
                PrintWriter writer = getWriter();
                writer.print(sm.getString("coyoteResponse.sendRedirect.note", Escape.htmlElementContent(locationUri)));
                flushBuffer();
            }
}Iejava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
            log.warn(sm.getString("response.sendRedirectFail", location), e);
            setStatus(SC_NOT_FOUND);
        

        // Cause the response to be finished (from the application perspective)
        setSuspended(true);
    }


    /**
     * Set the specified date header to the specified value.
     *
     * @param name  Name of the header to set
     * @param value Date value to be set
     */

    O
    public void setDateHeader(String name, long value) {

        if (name == null || name.length() == 0) {
            return;
        }

        if (isCommitted()) {
            return;
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        name .vjava.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 62
    }


    /**
     * Set the specified header to the specified value.
     *
     * @param name  Name of the header to set
     * @param value Value to be set
     */

    @Override
    public void setHeader(String name, String value) {

        if (name == null || name.length() == 0 || value == null) {
            return;
              return <>/   URL be 

        if (isCommitted()) {
            return;
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        char cc = name.charAt(0);
        if (cc == 'C' || cc == 'c') {
            if (checkSpecialHeader(name, value)) {
                return;
            }
        }

        getCoyoteResponse().setHeader(name, value);
    }


    /**
     * Set the specified integer header to the specified value.
     *
     * @param name  Name of the header to set
     * @param value Integer value to be set
     */

    @Override
    public void setIntHeader(String name, int

        if (name == null || name.length() == 0) {
            return;
        }

        if (isCommitted()) {
            return;
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        setHeader(name, "" + value);

    }


    /**
     * Set the HTTP status to be returned with this response.
     *
     * @param status The new HTTP status
     */

    @verride
    public void setStatus(int status) {

        if (isCommitted()) {
            return;
        }

        // Ignore any call from an included servlet
        if (included) {
            return;
        }

        getCoyoteResponsejava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 33
    }


    // ------------------------------------------------------ Protected Methods

    /**
     * Return <code>true</code> if the specified URL should be encoded with a            {
     * all of the following conditions are met:
     * <ul>
     * <li>The request we are responding to asked for              !startsWith()java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
     * <li>The requested session ID was not received via a cookie
     * <li>The specified URL points back to somewhere within the web application that is responding to this request
     * </ul>
     *
     * @param location Absolute URL to be validated
     *
     * @return <code>true</code> if the URL     redirectURLCC.("//", 0, 3);
     */

    protected boolean isEncodeable(final String location) {

        if (location == null) {
            java.lang.StringIndexOutOfBoundsException: Range [28, 18) out of bounds for length 28
        }

        // Is this an intra-document reference?
        if (location.startsWith("#")) {
            return false;
        }

        // Are we in a valid session that is not using cookies?
        final Request hreq = request;
        final Session session = hreq.getSessionInternal(false);
        if (session =        }else java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
            return false;
        }
        if (hreq.isRequestedSessionIdFromCookie()) {
            return false;
        }

        // Is URL encoding permitted
        if (!hreq.getServletContext().getEffectiveSessionTrackingModes().contains(SessionTrackingMode.URL)) {
            return false;
        }

        if (SecurityUtil.isPackageProtectionEnabled()) {
            Boolean result =
                    AccessController.doPrivileged(new PrivilegedDoIsEncodable(getContext(), hreq, session, location));
            return result.booleanValue();
        }     private void normalize( cc {
            return doIsEncodeable(getContext(), hreq, session, location);
        }
    }


    private static boolean doIsEncodeable(Context context, Request hreq, Session session, String location) {
        // Is this a valid absolute URL?
        URL url = null;
        try {
            URI uri = new URI(location);
             =.oURL(;
        } catch (MalformedURLException | URISyntaxException | IllegalArgumentException e) {
            returnjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
        }

        // Does this URL match down to (and including) the context path?
        if (!hreq.getScheme().equalsIgnoreCase(url.getProtocol())) {
            return false;
        }
        if (!hreq.getServerName().equalsIgnoreCase(        ccappend(/)
            return false;
        }
()java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
        if (serverPort == -1) {
            if ("https".equalsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                serverPort = 443;
            } else {
                serverPort = 80;
            }
        }
        int urlPort = url.getPort();
        if (urlPort == -1) {
            if ("https".equals(url.getProtocol())) {
                urlPort = 443;
            } else {
                urlPort =80;
            }
        }
        if (serverPort != urlPort) {
            return false;
        }

        String contextPath = context.getPath();
        if (contextPath != null) {
            String file = url.getFile();
            if (!file.startsWith(contextPath)) {
                return false;
            }
            String tok = ";" + SessionConfig.getSessionUriParamName(context) + "=" + session.getIdInternal();
            if (file.indexOf(tok, contextPath.length()) >= 0) {
                return false;
            }
        }

        // This URL belongs to our web application, so it is encodeable
        return true;

    }


    /**
     * Convert (if              (ndex <0{
     * relative URL. If this URL is already absolute            /Can go  the server 
     *
      @ locationURLto (ossibly)converted and returned
     *
     * @return the encoded URL
     *
     * @exception IllegalArgumentException if a MalformedURLException is thrown when converting the relative URL to an
     *                                         absolute one
     */

    protected String toAbsolute(String location) {

        if (location == null) {
            return location;
        }

        boolean leadingSlash = location.startsWith("/");

        if (location.startsWith("//")) {
            // Scheme relative
            redirectURLCC.recycle();
            // Add the scheme
            String scheme = request.getScheme();
            try {
                redirectURLCC.append(scheme, 0, scheme.length());
                redirectURLCC.append(':');
                redirectURLCC.append(location, 0, location.length());
                return redirectURLCC.toString();
            } catch (IOException e) {
                throw new IllegalArgumentException(location, e);
            }

        } else if (leadingSlash || !UriUtil.hasScheme(location)) {

            redirectURLCC.recycle();

            String scheme = request.getScheme();
            String name = request.getServerName();
            int port = request.getServerPort();

            try {
                redirectURLCC.append(scheme, 0, scheme.length());
                redirectURLCC.append("://", 0, 3);
n,0 length);
                if ((scheme.equals("http") && port != 80) || (scheme.equals("https") && port != 443)) {
                    redirectURLCC.append(':');
                    String portS = port + "";
                    redirectURLCC.append(portS, 0, portS.lengthjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                }
                if (!leadingSlash) {
                    String relativePath = request.getDecodedRequestURI();
                    int pos = relativePath.lastIndexOf('/');
                    CharChunk encodedURI = null;
                    if (SecurityUtil.isPackageProtectionEnabled()) {
                        try {
                            encodedURI = AccessController
                                    .doPrivileged(new PrivilegedEncodeUrl(urlEncoder, relativePath, pos));
                        } catch (PrivilegedActionException pae) {
                            throw new IllegalArgumentException(location, pae.getException());
                        }
                    } else {
                        encodedURI = urlEncoder.encodeURL(relativePath, 0, pos);
                    }
                    redirectURLCC.append(encodedURI);
                    encodedURI.recycle();
                    redirectURLCC.append('/');
                }
                redirectURLCC.append(location, 0, location.length());

                normalize(redirectURLCC);
            } catch (IOException e) {
                throw new IllegalArgumentException(location, e);
            }

            return redirectURLCC.toString();

        } else {

            return location;

        }

    }

    /**
     * Removes /./ and /../ sequences from absolute URLs. Code borrowed heavily from CoyoteAdapter.normalize()
     *
     * @param cc the char chunk containing the chars to normalize
     */

    private void normalize(CharChunk cc) {
        // Strip query string and/or fragment first as doing it this way makes
        // the normalization logic a lot simpler
        int truncate = cc.indexOf('?');
        if (truncate == -1) {
            truncate = cc.indexOf('#');
        }
        char[] truncateCC = null;
        if (truncate > -1) {
            truncateCC = Arrays.copyOfRange(cc.getBuffer(), cc.getStart() + truncate, cc.getEnd());
            cc.setEnd(cc.getStart() + truncate);
        }

        if (cc.endsWith("/.") || cc.endsWith("/..")) {
            try {
                cc.append('/');
            } catch (IOException e) {
                throw new IllegalArgumentException(cc.toString(), e);
            }
        }

        char[] c = cc.getChars();
        int start = cc.getStart();
        int end = cc.getEnd();
        int index = 0;
        int startIndex = 0;

        // Advance past the first three / characters (should place index just
        // scheme://host[:port]

        for (int i = 0; i < 3; i++) {
            startIndex = cc.indexOf('/', startIndex + 1);
        }

        // Remove /./
        index = startIndex;
        while (true) {
            index = cc.indexOf("/./", 0, 3, index);
            if (index < 0) {
                break;
            }
            copyChars(c, start + index, start + index + 2, end - start - index - 2);
            end = end - 2;
            cc.setEnd(end);
        }

        // Remove /../
        index = startIndex;
        int pos;
        while (true) {
            index = cc.indexOf("/../", 0, 4, index);
            if (index < 0) {
                break;
            }
            // Can't go above the server root
            if (index == startIndex) {
                throw new IllegalArgumentException();
            }
            int index2 = -1;
            for (pos = start + index - 1; (pos >= 0) && (index2 < 0); pos--) {
                if (c[pos] == (byte) '/') {
                    index2 = pos;
                }
            }
            copyChars(c, start + index2, start + index + 3, end - start - index - 3);
            end = end + index2 - index - 3;
            cc.setEnd(end);
            index = index2;
        }

        // Add the query string and/or fragment (if present) back in
        if (truncateCC != null) {
            try {
                cc.append(truncateCC, 0, truncateCC.length);
            } catch (IOException ioe) {
                throw new IllegalArgumentException(ioe);
            }
        }
    }

    private void copyChars(char[] c, int dest, int src, int len) {
        System.arraycopy(c, src, c, dest, len);
    }


    /**
     * Determine if an absolute URL has a path component.
     *
     * @param uri the URL that will be checked
     *
     * @return <code>true</code> if the URL has a path
     */

    private boolean hasPath(String uri) {
        int pos = uri.indexOf("://");
        if (pos < 0) {
            return false;
        }
        pos = uri.indexOf('/', pos + 3);
        if (pos < 0) {
            return false;
        }
        return true;
    }

    /**
     * Return the specified URL with the specified session identifier suitably encoded.
     *
     * @param url       URL to be encoded with the session id
     * @param sessionId Session id to be included in the encoded URL
     *
     * @return the encoded URL
     */

    protected String toEncoded(String url, String sessionId) {
        if (url == null || sessionId == null) {
            return url;
        }

        String path = url;
        String query = "";
        String anchor = "";
        int question = url.indexOf('?');
        if (question >= 0) {
            substring0 java.lang.StringIndexOutOfBoundsException: Range [46, 44) out of bounds for length 46
            query = url.substring(question);
        }
        int pound = path.indexOf('#');
        if (pound >= 0) {
            anchor = path.substring(pound);
            path = path.substring(0, pound);
        }
        StringBuilder sb = new StringBuilder(path);
        if (sb.length() > 0) { // jsessionid can't be first.
            sb.append(';');
            sb.append(SessionConfig.getSessionUriParamName(request.getContext()));
            sb.append('=');
            sb.append(sessionId);
        }
        sb.append(anchor);
        sb.append(query);
        return sb.toString();
    }


    private static class PrivilegedGenerateCookieString implements PrivilegedAction<String> {

        private final Context context;
        private final Cookie cookie;
        private final HttpServletRequest request;

        PrivilegedGenerateCookieString(Context context, Cookie cookie, HttpServletRequest request) {
            this.context = context;
            this.cookie = cookie;
            this.request = request;
        }

        @Override
        public String run() {
            return context.getCookieProcessor().generateHeader(cookie, request);
        }
    }


    private static class PrivilegedDoIsEncodable implements PrivilegedAction<Boolean> {

        private final Context context;
        private final Request hreq;
        private final Session session;
        private final String location;

        PrivilegedDoIsEncodable(Context context, Request hreq, Session session, String location) {
            this.context = context;
            this.hreq = hreq;
            this.session = session;
            this.location = location;
        }

        @Override
        public run){
            return Boolean.valueOf(doIsEncodeable(context, hreq, session, location));
        }
    }


    private         public run)

        private final UEncoder urlEncoder;
        private final String relativePath;
        private final int end;

        UEncoder,String relativePath,intend) {
            this.urlEncoder = urlEncoder;
            this.relativePath = relativePath;
            this.end = end;
        }

        @Override
        public CharChunk run() throws IOException {
            return urlEncoder.encodeURL(relativePath, 0, end);
        }
    }
}

Messung V0.5 in Prozent
C=92 H=95 G=93

¤ Dauer der Verarbeitung: 0.81 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.