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

## ix.util.http
Class HttpStringClient

    java.lang.Object
      ix.util.http.HttpObjectClient
          ix.util.http.HttpStringClient

    public class HttpStringClient

extends HttpObjectClient

Makes HTTP requests that can be regarded as sending a string and receiving one in reply. The string may of course contain XML if desired.

Certain reasonable assumptions are made about the requests:

- The Content-Type for sending strings is "text/plain";
- The charset is UTF-8.

Both can be changed by calling "set" methods.

At present, only POST requests can be made.

See Also:
  `HttpStringServlet`, `HttpServer`

Field Summary

Fields inherited from class ix.util.http.HttpObjectClient
`requestCharsetName, requestContentType, util`

Constructor Summary
`HttpStringClient()`

Method Summary
`protected java.lang.String` | `decodeReceived(java.lang.String contents)` Turns response contents into an object.
`protected byte[]` | `encodeForSend(java.lang.Object obj)` Turns an object into request contents.
`static void` | `main(java.lang.String[] argv)` Main program for testing.
`java.lang.String` | `sendRequest(java.net.URL url, java.lang.Object contentsToSend)` Send a string and receive one in reply.

Methods inherited from class ix.util.http.HttpObjectClient
`describeResponse, handleResponseCode, handleResponseCode, mainLoop, readReply, sendBytes, setRequestCharsetName, setRequestContentType`

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

Constructor Detail

### HttpStringClient

    public HttpStringClient()

Method Detail

### sendRequest

    public java.lang.String sendRequest(java.net.URL url,
                                        java.lang.Object contentsToSend)

  Send a string and receive one in reply. If an object that isn't a string is given as the contents to send, it is converted to a string by calling it's `toString()` method.

  Overrides:
    `sendRequest` in class `HttpObjectClient`

### encodeForSend

    protected byte[] encodeForSend(java.lang.Object obj)
                            throws java.io.UnsupportedEncodingException

  Description copied from class: `HttpObjectClient`
  Turns an object into request contents.

  Overrides:
    `encodeForSend` in class `HttpObjectClient`
  Throws:
    `java.io.UnsupportedEncodingException`
  See Also:
    `HttpObjectClient.decodeReceived(String contents)`

### decodeReceived

    protected java.lang.String decodeReceived(java.lang.String contents)

  Description copied from class: `HttpObjectClient`
  Turns response contents into an object. For example, the content might be an XML representation of an object.

  Overrides:
    `decodeReceived` in class `HttpObjectClient`
  See Also:
    `HttpObjectClient.encodeForSend(Object contents)`

### main

    public static void main(java.lang.String[] argv)
                     throws java.lang.Exception

  Main program for testing.

  Throws:
    `java.lang.Exception`

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