| 1 |
/* |
| 2 |
* Copyright 1999-2010 University of Chicago |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 |
* express or implied. |
| 12 |
* |
| 13 |
* See the License for the specific language governing permissions and limitations under the License. |
| 14 |
*/ |
| 15 |
package org.globus.util.http; |
| 16 |
|
| 17 |
import java.io.InputStream; |
| 18 |
import java.io.IOException; |
| 19 |
|
| 20 |
public class HTTPRequestParser extends HTTPParser { |
| 21 |
|
| 22 |
protected String _requestType; |
| 23 |
protected String _service; |
| 24 |
|
| 25 |
public HTTPRequestParser(InputStream is) |
| 26 |
throws IOException { |
| 27 |
super(is); |
| 28 |
} |
| 29 |
|
| 30 |
public String getService() { |
| 31 |
return _service; |
| 32 |
} |
| 33 |
|
| 34 |
public void setService(String service) { |
| 35 |
_service = service; |
| 36 |
} |
| 37 |
|
| 38 |
public void parseHead(String line) |
| 39 |
throws IOException { |
| 40 |
int st = line.indexOf(" "); |
| 41 |
if (st == -1) { |
| 42 |
throw new IOException("Bad HTTP header"); |
| 43 |
} |
| 44 |
_requestType = line.substring(0, st); |
| 45 |
|
| 46 |
st++; |
| 47 |
int et = line.indexOf(" ", st); |
| 48 |
if (et == -1) { |
| 49 |
throw new IOException("Bad HTTP header"); |
| 50 |
} |
| 51 |
_service = line.substring(st, et); |
| 52 |
|
| 53 |
et++; |
| 54 |
} |
| 55 |
|
| 56 |
} |