⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpexchange.java

📁 是离开的肌肤了卡机是离开的就富利卡及是了的开发及拉考试及的福利科技阿斯利康的肌肤莱卡及时的离开福建阿斯顿发
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }    /* ------------------------------------------------------------ */    /**     * @return     */    public String getURI()    {        return _uri;    }    /* ------------------------------------------------------------ */    /**     * @param uri     */    public void setURI(String uri)    {        _uri = uri;    }    /* ------------------------------------------------------------ */    /**     * @param name     * @param value     */    public void addRequestHeader(String name, String value)    {        getRequestFields().add(name,value);    }    /* ------------------------------------------------------------ */    /**     * @param name     * @param value     */    public void addRequestHeader(Buffer name, Buffer value)    {        getRequestFields().add(name,value);    }    /* ------------------------------------------------------------ */    /**     * @param name     * @param value     */    public void setRequestHeader(String name, String value)    {        getRequestFields().put(name,value);    }    /* ------------------------------------------------------------ */    /**     * @param name     * @param value     */    public void setRequestHeader(Buffer name, Buffer value)    {        getRequestFields().put(name,value);    }    /* ------------------------------------------------------------ */    /**     * @param value     */    public void setRequestContentType(String value)    {        getRequestFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,value);    }    /* ------------------------------------------------------------ */    /**     * @return     */    public HttpFields getRequestFields()    {        return _requestFields;    }    /* ------------------------------------------------------------ */    /* ------------------------------------------------------------ */    /* ------------------------------------------------------------ */    // methods to commit and/or send the request    /* ------------------------------------------------------------ */    /**     * @param requestContent     */    public void setRequestContent(Buffer requestContent)    {        _requestContent = requestContent;    }    /* ------------------------------------------------------------ */    /**     * @param in     */    public void setRequestContentSource(InputStream in)    {        _requestContentSource = in;    }    /* ------------------------------------------------------------ */    public InputStream getRequestContentSource()    {        return _requestContentSource;    }    /* ------------------------------------------------------------ */    public Buffer getRequestContentChunk() throws IOException    {        synchronized (this)        {            if (_requestContentChunk == null)                _requestContentChunk = new ByteArrayBuffer(4096); // TODO configure            else            {                if (_requestContentChunk.hasContent())                    throw new IllegalStateException();                _requestContentChunk.clear();            }            int read = _requestContentChunk.capacity();            int length = _requestContentSource.read(_requestContentChunk.array(),0,read);            if (length >= 0)            {                _requestContentChunk.setPutIndex(length);                return _requestContentChunk;            }            return null;        }    }    /* ------------------------------------------------------------ */    public Buffer getRequestContent()    {        return _requestContent;    }    public boolean getRetryStatus()    {        return _retryStatus;    }    public void setRetryStatus( boolean retryStatus )    {        _retryStatus = retryStatus;    }    /* ------------------------------------------------------------ */    /** Cancel this exchange     * Currently this implementation does nothing.     */    public void cancel()    {    }    /* ------------------------------------------------------------ */    public String toString()    {        return "HttpExchange@" + hashCode() + "=" + _method + "//" + _address.getHost() + ":" + _address.getPort() + _uri + "#" + _status;    }    /* ------------------------------------------------------------ */    /* ------------------------------------------------------------ */    /* ------------------------------------------------------------ */    // methods to handle response    protected void onRequestCommitted() throws IOException    {    }    protected void onRequestComplete() throws IOException    {    }    protected void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException    {    }    protected void onResponseHeader(Buffer name, Buffer value) throws IOException    {    }    protected void onResponseHeaderComplete() throws IOException    {    }    protected void onResponseContent(Buffer content) throws IOException    {    }    protected void onResponseComplete() throws IOException    {    }    protected void onConnectionFailed(Throwable ex)    {        Log.warn("CONNECTION FAILED on " + this,ex);    }    protected void onException(Throwable ex)    {        Log.warn("EXCEPTION on " + this,ex);    }    protected void onExpire()    {        Log.warn("EXPIRED " + this);    }    protected void onRetry() throws IOException    {}    /**     * true of the exchange should have listeners configured for it by the destination     *     * false if this is being managed elsewhere     *     * @return     */    public boolean configureListeners()    {        return _configureListeners;    }    public void setConfigureListeners(boolean autoConfigure )    {        this._configureListeners = autoConfigure;    }    private class Listener implements HttpEventListener    {        public void onConnectionFailed(Throwable ex)        {            HttpExchange.this.onConnectionFailed(ex);        }        public void onException(Throwable ex)        {            HttpExchange.this.onException(ex);        }        public void onExpire()        {            HttpExchange.this.onExpire();        }        public void onRequestCommitted() throws IOException        {            HttpExchange.this.onRequestCommitted();        }        public void onRequestComplete() throws IOException        {            HttpExchange.this.onRequestComplete();        }        public void onResponseComplete() throws IOException        {            HttpExchange.this.onResponseComplete();        }        public void onResponseContent(Buffer content) throws IOException        {            HttpExchange.this.onResponseContent(content);        }        public void onResponseHeader(Buffer name, Buffer value) throws IOException        {            HttpExchange.this.onResponseHeader(name,value);        }        public void onResponseHeaderComplete() throws IOException        {            HttpExchange.this.onResponseHeaderComplete();        }        public void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException        {            HttpExchange.this.onResponseStatus(version,status,reason);        }        public void onRetry()        {            HttpExchange.this.setRetryStatus( true );            try            {                HttpExchange.this.onRetry();            }            catch (IOException e)            {                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.            }        }    }    /**     * @deprecated use {@link org.mortbay.jetty.client.CachedExchange}     *     */    public static class CachedExchange extends org.mortbay.jetty.client.CachedExchange    {        public CachedExchange(boolean cacheFields)        {            super(cacheFields);        }    }    /**     * @deprecated use {@link org.mortbay.jetty.client.ContentExchange}     *     */    public static class ContentExchange extends org.mortbay.jetty.client.ContentExchange    {    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -