HTTPClient icon

HTTPClient For Linux

  n/a
LGPL    

HTTPClient provides a complete http client library.. #HTTP library  #HTTP client  #Www library  #HTTPClient  #HTTP  #Client  

Description

Free Download

This package provides a complete http client library. It currently implements most of the relevant parts of the HTTP/1.0 and HTTP/1.1 protocols, including the request methods HEAD, GET, POST and PUT, and automatic handling of authorization, redirection requests, and cookies.

Furthermore the included Codecs class contains coders and decoders for the base64, quoted-printable, URL-encoding, chunked and the multipart/form-data encodings. The whole thing is free, and licenced under the GNU Lesser General Public License (LGPL) (note that this is not the same as the GPL).

Following are the kits and documentation for the HTTPClient Version 0.3-3. If you have any problems, bugs, suggestions, comments, etc. see the info on debugging and reporting problems. An older version of these pages are also available in Japanese, thanks to the kindly efforts of Yuji Kumasaka.

Using the HTTPClient should be quite simple. First add the import statement import HTTPClient.*; to your file(s). Next you create an instance of HTTPConnection (you'll need one for every server you wish to talk to). Requests can then be sent using one of the methods Head(), Get(), Post(), etc in HTTPConnection.

These methods all return an instance of HTTPResponse which has methods for accessing the response headers (getHeader(), getHeaderAsInt(), etc), various response info (getStatusCode(), getReasonLine(), etc), the response data (getData(), getText(), and getInputStream()) and any trailers that might have been sent (getTrailer(), getTrailerAsInt(), etc). Following are some examples to get started. To retrieve files from the URL "http://www.myaddr.net/my/file" you can use something like the following: try { HTTPConnection con = new HTTPConnection("www.myaddr.net"); HTTPResponse rsp = con.Get("/my/file"); if (rsp.getStatusCode() >= 300) { System.err.println("Received Error: "+rsp.getReasonLine()); System.err.println(rsp.getText()); } else data = rsp.getData();

rsp = con.Get("/another_file"); if (rsp.getStatusCode() >= 300) { System.err.println("Received Error: "+rsp.getReasonLine()); System.err.println(rsp.getText()); } else other_data = rsp.getData(); } catch (IOException ioe) { System.err.println(ioe.toString()); } catch (ParseException pe) { System.err.println("Error parsing Content-Type: " + pe.toString()); } catch (ModuleException me) { System.err.println("Error handling request: " + me.getMessage()); }

This will get the files "/my/file" and "/another_file" and put their contents into byte[]'s accessible via getData(). Note that you need to only create a new HTTPConnection when sending a request to a new server (different protocol, host or port); although you may create a new HTTPConnection for every request to the same server this not recommended, as various information about the server is cached after the first request (to optimize subsequent requests) and persistent connections are used whenever possible (see also Advanced Info).

To POST form data from an applet back to your server you could use something like this (assuming you have two fields called name and e-mail, whose contents are stored in the variables name and email): try { NVPair form_data[] = new NVPair[2]; form_data[0] = new NVPair("name", name); form_data[1] = new NVPair("e-mail", email);

// note the convenience constructor for applets HTTPConnection con = new HTTPConnection(this); HTTPResponse rsp = con.Post("/cgi-bin/my_script", form_data); if (rsp.getStatusCode() >= 300) { System.err.println("Received Error: "+rsp.getReasonLine()); System.err.println(rsp.getText()); } else stream = rsp.getInputStream(); } catch (IOException ioe) { System.err.println(ioe.toString()); } catch (ModuleException me) { System.err.println("Error handling request: " + me.getMessage()); }

Here the response data is read at leisure via an InputStream instead of all at once into a byte[].

As another example, if you want to upload a document to a URL (and the server supports http PUT) you could do something like the following: try { URL url = new URL("http://www.mydomain.us/test/my_file");

HTTPConnection con = new HTTPConnection(url); HTTPResponse rsp = con.Put(url.getFile(), "Hello World"); if (rsp.getStatusCode() >= 300) { System.err.println("Received Error: "+rsp.getReasonLine()); System.err.println(rsp.getText()); } else text = rsp.getText(); } catch (IOException ioe) { System.err.println(ioe.toString()); } catch (ModuleException me) { System.err.println("Error handling request: " + me.getMessage()); }

HTTPClient 0.3-3

add to watchlist add to download basket send us an update REPORT
  runs on:
Linux
  filename:
HTTPClient.tar.gz
  main category:
Internet
  developer:
  visit homepage

calibre 7.9.0

Effortlessly keep your e-book library thoroughly organized with the help of the numerous features offered by this efficient and capable manager
calibre

IrfanView 4.67

With support for a long list of plugins, this minimalistic utility helps you view images, as well as edit and convert them using a built-in batch mode
IrfanView

Windows Sandbox Launcher 1.0.0

Set up the Windows Sandbox parameters to your specific requirements, with this dedicated launcher that features advanced parametrization
Windows Sandbox Launcher

Zoom Client 6.0.3.37634

The official desktop client for Zoom, the popular video conferencing and collaboration tool used by millions of people worldwide
Zoom Client

Microsoft Teams 24060.3102.2733.5911 Home / 1.7.00.7956 Work

Effortlessly chat, collaborate on projects, and transfer files within a business-like environment by employing this Microsoft-vetted application
Microsoft Teams

ShareX 16.0.1

Capture your screen, create GIFs, and record videos through this versatile solution that includes various other amenities: an OCR scanner, image uploader, URL shortener, and much more
ShareX

7-Zip 23.01 / 24.04 Beta

An intuitive application with a very good compression ratio that can help you not only create and extract archives, but also test them for errors
7-Zip

4k Video Downloader 1.5.3.0080 Plus / 4.30.0.5655

Export your favorite YouTube videos and playlists with this intuitive, lightweight program, built to facilitate downloading clips from the popular website
4k Video Downloader

Bitdefender Antivirus Free 27.0.35.146

Feather-light and free antivirus solution from renowned developer that keeps the PC protected at all times from malware without requiring user configuration
Bitdefender Antivirus Free

Context Menu Manager 3.3.3.1

Customize Windows’ original right-click context menu using this free, portable and open-source utility meant to enhance your workflow
Context Menu Manager

% discount
4k Video Downloader
  • 4k Video Downloader
  • Bitdefender Antivirus Free
  • Context Menu Manager
  • calibre
  • IrfanView
  • Windows Sandbox Launcher
  • Zoom Client
  • Microsoft Teams
  • ShareX
  • 7-Zip
essentials


Load comments
This enables Disqus, Inc. to process some of your data. Disqus privacy policy