1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.squareup.okhttp.internal.http;
18
19import java.io.IOException;
20import java.io.OutputStream;
21
22/**
23 * An output stream for the body of an HTTP request.
24 *
25 * <p>Since a single socket's output stream may be used to write multiple HTTP
26 * requests to the same server, subclasses should not close the socket stream.
27 */
28abstract class AbstractHttpOutputStream extends OutputStream {
29  protected boolean closed;
30
31  @Override public final void write(int data) throws IOException {
32    write(new byte[] { (byte) data });
33  }
34
35  protected final void checkNotClosed() throws IOException {
36    if (closed) {
37      throw new IOException("stream closed");
38    }
39  }
40}
41