Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mindprod.http
Class Get

    java.lang.Object
      com.mindprod.http.Get

    public final class Get

extends java.lang.Object

simulates a browser posting a form to CGI via GET.

See com.mindprod.submitter for sample code to use this class.

Since:
  1998
Version:
  2.1 2010-02-07 - new methods Post.setBody Http.setRequestProperties.
Author:
  Roedy Green, Canadian Mind Products

Constructor Summary
`Get()` constructor

Method Summary
`static java.lang.String` | `encodeParms(java.lang.String encoding, java.lang.String... parms)` encode a set of parms for the command, separated with ? = & = * This method does not automatically include the result in the message sent to the host.
`java.lang.String` | `getReferer()` ges the Referrer ie.
`int` | `getResponseCode()` responseCode from most recent post/get Meaning of various codes are described at HttpURLConnection and at http://mindprod.com/jgloss/http.html
`java.lang.String` | `getResponseMessage()` responseCode from most recent post/get
`java.lang.String` | `send(java.lang.String host, int port, java.lang.String action, java.lang.String encoding)` Send a form full of data to the CGI host using GET.
`java.lang.String` | `send(java.net.URL url, java.lang.String encoding)` Send a form full of data to the CGI host using GET.
`void` | `setConnectTimeout(int connectTimeout)` override the default connect timeout of 50 seconds
`void` | `setParms(java.lang.String... parms)` set the parms that will be send tacked onto the end of the URL, get-style
`void` | `setReadTimeout(int readTimeout)` override the default read timeout of 40 seconds
`void` | `setReferer(java.lang.String referer)` set the Referrer ie.
`void` | `setRequestProperties(java.lang.String... requestProperties)` set additional requestProperties.
`protected void` | `setStandardProperties(java.net.URLConnection urlc)` set up the standard properties on the connection
`void` | `setUserAgent(java.lang.String userAgent)` override the default User-Agent

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Get

    public Get()

  constructor

Method Detail

### send

    public java.lang.String send(java.net.URL url,
                                 java.lang.String encoding)

  Send a form full of data to the CGI host using GET.

  Parameters:
    `url` - complete URL including get parms, pre-encoded.
    `encoding` - encoding of the byte stream result, usually UTF-8 or or ISO-8859-1.
  Returns:
    CGI host's response with headers and embedded length fields stripped.
  See Also:
    "com.mindprod.http.Get"

### send

    public java.lang.String send(java.lang.String host,
                                 int port,
                                 java.lang.String action,
                                 java.lang.String encoding)

  Send a form full of data to the CGI host using GET. Must have previously specified the parms with setParms.

  Parameters:
    `host` - host name of the website, Should be form:"mindprod.com", no lead http://.
    `port` - -1 if default, 8081 for local echoserver.
    `action` - action of form, page on website. Usually has a lead / and no trailing /.
    `encoding` - encoding of the byte stream result, usually UTF-8 or or ISO-8859-1.
  Returns:
    CGI host's response with headers and embedded length fields stripped.

### encodeParms

    public static java.lang.String encodeParms(java.lang.String encoding,
                                               java.lang.String... parms)
                                        throws java.io.UnsupportedEncodingException

  encode a set of parms for the command, separated with ? = & = * This method does not automatically include the result in the message sent to the host.

  Parameters:
    `encoding` - for URLEncoder
    `parms` - 0..n strings to be send as parameter, alternating keyword/value
  Returns:
    all the parms in one string encoded with lead ?
  Throws:
    `java.io.UnsupportedEncodingException` - if bad encoding

### getReferer

    public java.lang.String getReferer()

  ges the Referrer ie. the name of a web page this request ostensibly came from.

  Returns:
    referrer e.g "http://mindprod.com/index.html", null for none.
  See Also:
    details on Referrer

### setReferer

    public void setReferer(java.lang.String referer)

  set the Referrer ie. the name of a web page this request ostensibly came from. Note that the word Referrer is spelled incorrectly as Referer the HTTP spec.

  Parameters:
    `referer` - e.g "http://mindprod.com/index.html", null for none.
  See Also:
    details on Referrer

### getResponseCode

    public int getResponseCode()

  responseCode from most recent post/get Meaning of various codes are described at HttpURLConnection and at http://mindprod.com/jgloss/http.html

  Returns:
    responseCode
  See Also:
    `HttpURLConnection`

### getResponseMessage

    public java.lang.String getResponseMessage()

  responseCode from most recent post/get

  Returns:
    responseCode

### setConnectTimeout

    public void setConnectTimeout(int connectTimeout)

  override the default connect timeout of 50 seconds

  Parameters:
    `connectTimeout` - timeout to connect in ms. Note int, not long.

### setParms

    public void setParms(java.lang.String... parms)

  set the parms that will be send tacked onto the end of the URL, get-style

  Parameters:
    `parms` - 0..n strings to be send as parameter, alternating keyword/value
  See Also:
    `Post.setPostParms(String...)`

### setReadTimeout

    public void setReadTimeout(int readTimeout)

  override the default read timeout of 40 seconds

  Parameters:
    `readTimeout` - timeout to connect int ms. Note int, not long.

### setRequestProperties

    public void setRequestProperties(java.lang.String... requestProperties)

  set additional requestProperties. Replaced previous set.

  Parameters:
    `requestProperties` - pairs: key value.

### setUserAgent

    public void setUserAgent(java.lang.String userAgent)

  override the default User-Agent

  Parameters:
    `userAgent` - User-Agent a browser uses in an HTTP header to identify itself. null for no User Agent. By default you get Firefox.
  See Also:
    details on User-Agent

### setStandardProperties

    protected void setStandardProperties(java.net.URLConnection urlc)

  set up the standard properties on the connection

  Parameters:
    `urlc` - Connection we are setting up.

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD