Java 类org.apache.commons.httpclient.HttpParser 实例源码

项目:lib-commons-httpclient    文件:SimpleHttpServerConnection.java   
public SimpleRequest readRequest() throws IOException {
    try {
        String line = null;
        do {
            line = HttpParser.readLine(in, HTTP_ELEMENT_CHARSET);
        } while (line != null && line.length() == 0);

        if (line == null) {
            setKeepAlive(false);
            return null;
        }
        SimpleRequest request = new SimpleRequest( 
                RequestLine.parseLine(line),
                HttpParser.parseHeaders(this.in, HTTP_ELEMENT_CHARSET),
                this.in);
        return request;
    } catch (IOException e) {
        close();
        throw e;
    }
}
项目:lib-commons-httpclient    文件:SimpleHttpServerConnection.java   
public SimpleResponse readResponse() throws IOException {
    try {
        String line = null;
        do {
            line = HttpParser.readLine(in, HTTP_ELEMENT_CHARSET);
        } while (line != null && line.length() == 0);

        if (line == null) {
            setKeepAlive(false);
            return null;
        }
        SimpleResponse response = new SimpleResponse(
                new StatusLine(line),
                HttpParser.parseHeaders(this.in, HTTP_ELEMENT_CHARSET),
                this.in);
        return response;
    } catch (IOException e) {
        close();
        throw e;
    }
}
项目:httpclient3-ntml    文件:SimpleHttpServerConnection.java   
public SimpleRequest readRequest() throws IOException {
    try {
        String line = null;
        do {
            line = HttpParser.readLine(in, HTTP_ELEMENT_CHARSET);
        } while (line != null && line.length() == 0);

        if (line == null) {
            setKeepAlive(false);
            return null;
        }
        SimpleRequest request = new SimpleRequest( 
                RequestLine.parseLine(line),
                HttpParser.parseHeaders(this.in, HTTP_ELEMENT_CHARSET),
                this.in);
        return request;
    } catch (IOException e) {
        close();
        throw e;
    }
}
项目:httpclient3-ntml    文件:SimpleHttpServerConnection.java   
public SimpleResponse readResponse() throws IOException {
    try {
        String line = null;
        do {
            line = HttpParser.readLine(in, HTTP_ELEMENT_CHARSET);
        } while (line != null && line.length() == 0);

        if (line == null) {
            setKeepAlive(false);
            return null;
        }
        SimpleResponse response = new SimpleResponse(
                new StatusLine(line),
                HttpParser.parseHeaders(this.in, HTTP_ELEMENT_CHARSET),
                this.in);
        return response;
    } catch (IOException e) {
        close();
        throw e;
    }
}
项目:netarchivesuite-svngit-migration    文件:NetarchiveSuiteWARCRecordToSearchResultAdapter.java   
private CaptureSearchResult adaptWARCHTTPResponse(CaptureSearchResult result,
        WARCRecord rec) throws IOException {

    ArchiveRecordHeader header = rec.getHeader();
    // need to parse the documents HTTP message and headers here: WARCReader
    // does not implement this... yet..

       byte [] statusBytes = HttpParser.readRawLine(rec);
       int eolCharCount = getEolCharsCount(statusBytes);
       if (eolCharCount <= 0) {
           throw new RecoverableIOException("Failed to read http status where one " +
                   " was expected: " + 
                   ((statusBytes == null) ? "(null)" : new String(statusBytes)));
       }
       String statusLine = EncodingUtil.getString(statusBytes, 0,
           statusBytes.length - eolCharCount, ARCConstants.DEFAULT_ENCODING);
       if ((statusLine == null) ||
               !StatusLine.startsWithHTTP(statusLine)) {
          throw new RecoverableIOException("Failed parse of http status line.");
       }
       StatusLine status = new StatusLine(statusLine);
    result.setHttpCode(String.valueOf(status.getStatusCode()));

    Header[] headers = HttpParser.parseHeaders(rec,
               ARCConstants.DEFAULT_ENCODING);


    annotater.annotateHTTPContent(result,rec,headers,header.getMimetype());

    return result;
}
项目:archiventory    文件:ArcRecordReader.java   
private Header[] getHttpHeaders(ArchiveRecord nativeRecord) throws IOException {
    if (nativeRecord instanceof ARCRecord) {
        return ((ARCRecord) nativeRecord).getHttpHeaders();
    } else if (nativeRecord instanceof WARCRecord) {
        WARCRecord warcRecord = (WARCRecord) nativeRecord;
        if (warcRecord.hasContentHeaders()) {
            Header[] headers = HttpParser.parseHeaders(nativeRecord, DEFAULT_ENCODING);
            return headers;
        }
    }
    return new Header[0];
}
项目:webcurator    文件:ArcDigitalAssetStoreService.java   
private void skipHeaders(ArchiveRecord record) throws IOException {
    HttpParser.parseHeaders(record, WARCConstants.DEFAULT_ENCODING);
}