1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.http.impl.io;
29
30 import java.io.IOException;
31
32 import org.apache.http.HttpException;
33 import org.apache.http.HttpMessage;
34 import org.apache.http.HttpResponseFactory;
35 import org.apache.http.NoHttpResponseException;
36 import org.apache.http.ParseException;
37 import org.apache.http.StatusLine;
38 import org.apache.http.io.SessionInputBuffer;
39 import org.apache.http.message.LineParser;
40 import org.apache.http.message.ParserCursor;
41 import org.apache.http.params.HttpParams;
42 import org.apache.http.util.Args;
43 import org.apache.http.util.CharArrayBuffer;
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 @Deprecated
61 public class HttpResponseParser extends AbstractMessageParser<HttpMessage> {
62
63 private final HttpResponseFactory responseFactory;
64 private final CharArrayBuffer lineBuf;
65
66
67
68
69
70
71
72
73
74
75 public HttpResponseParser(
76 final SessionInputBuffer buffer,
77 final LineParser parser,
78 final HttpResponseFactory responseFactory,
79 final HttpParams params) {
80 super(buffer, parser, params);
81 this.responseFactory = Args.notNull(responseFactory, "Response factory");
82 this.lineBuf = new CharArrayBuffer(128);
83 }
84
85 @Override
86 protected HttpMessage parseHead(
87 final SessionInputBuffer sessionBuffer)
88 throws IOException, HttpException, ParseException {
89
90 this.lineBuf.clear();
91 final int readLen = sessionBuffer.readLine(this.lineBuf);
92 if (readLen == -1) {
93 throw new NoHttpResponseException("The target server failed to respond");
94 }
95
96 final ParserCursorursor.html#ParserCursor">ParserCursor cursor = new ParserCursor(0, this.lineBuf.length());
97 final StatusLine statusline = lineParser.parseStatusLine(this.lineBuf, cursor);
98 return this.responseFactory.newHttpResponse(statusline, null);
99 }
100
101 }