StatusLine.java

  1. /*
  2.  * Copyright (C) 2018, Thomas Wolf <thomas.wolf@paranor.ch> and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */
  10. package org.eclipse.jgit.internal.transport.sshd.proxy;

  11. /**
  12.  * A very simple representation of a HTTP status line.
  13.  */
  14. public class StatusLine {

  15.     private final String version;

  16.     private final int resultCode;

  17.     private final String reason;

  18.     /**
  19.      * Create a new {@link StatusLine} with the given response code and reason
  20.      * string.
  21.      *
  22.      * @param version
  23.      *            the version string (normally "HTTP/1.1" or "HTTP/1.0")
  24.      * @param resultCode
  25.      *            the HTTP response code (200, 401, etc.)
  26.      * @param reason
  27.      *            the reason phrase for the code
  28.      */
  29.     public StatusLine(String version, int resultCode, String reason) {
  30.         this.version = version;
  31.         this.resultCode = resultCode;
  32.         this.reason = reason;
  33.     }

  34.     /**
  35.      * Retrieves the version string.
  36.      *
  37.      * @return the version string
  38.      */
  39.     public String getVersion() {
  40.         return version;
  41.     }

  42.     /**
  43.      * Retrieves the HTTP response code.
  44.      *
  45.      * @return the code
  46.      */
  47.     public int getResultCode() {
  48.         return resultCode;
  49.     }

  50.     /**
  51.      * Retrieves the HTTP reason phrase.
  52.      *
  53.      * @return the reason
  54.      */
  55.     public String getReason() {
  56.         return reason;
  57.     }
  58. }