Code Monkey home page Code Monkey logo

icap-client's Introduction

icap-client

Simple Java ICAP Client for ICAP Services.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

What things you need to install the software and how to install them.

Java JDK 1.8 or higher.

Installing

Just clone this project on your favorite Java-Compatible IDE and have fun.

Examples

In this examples we are assuming that you are running an ICAP server on 127.0.0.1:1344. To run an ICAP server please see icap-server.

Send OPTIONS

ICAPClient icapClient = ICAPClient.instance("127.0.0.1", 1344);
icapClient.options("virus_scan");

This request will send the following bunch of data:

OPTIONS icap://127.0.0.1/virus_scan ICAP/1.0
Host: 127.0.0.1
User-Agent: Java-ICAP-Client/1.1
Encapsulated: null-body=0

Send REQMOD

ICAPClient icapClient = ICAPClient.instance("127.0.0.1", 1344);
ICAPRequest icapRequest = ICAPRequest.instance("virus_scan", ICAPRequest.Mode.REQMOD);
icapClient.execute(icapRequest);

This request will send the following bunch of data:

REQMOD icap://127.0.0.1/virus_scan ICAP/1.0
Host: 127.0.0.1
User-Agent: Java-ICAP-Client/1.1
Allow: 204
Encapsulated: null-body=0

Send RESPMOD

ICAPClient icapClient = ICAPClient.instance("127.0.0.1", 1344);
ICAPRequest icapRequest = ICAPRequest.instance("virus_scan", ICAPRequest.Mode.RESPMOD);
icapClient.execute(icapRequest);

This request will send the following bunch of data:

RESPMOD icap://127.0.0.1/virus_scan ICAP/1.0
Host: 127.0.0.1
User-Agent: Java-ICAP-Client/1.1
Allow: 204
Encapsulated: null-body=0

Deployment

mvn deploy

Built With

  • Maven - Dependency Management

Contributing

.

Versioning

This project uses SemVer for versioning.

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

icap-client's People

Contributors

aleksandarstojkovski avatar claudineyns avatar dependabot[bot] avatar vharseko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

icap-client's Issues

Socket Exception by using icap-client with File

Hallo,

thank you for providing your icap-Library on Github.
First i used your icap-Library to call my icap-server without uploading any file this works fine. The response Message from server contains status code 204.
But when i added a file with the setHttpRequestBody-Method i getting an exception.
This is my stacktracke:

Exception in thread "main" net.rfc3507.client.ICAPException: java.net.SocketException: Connection reset by peer: socket write error
at net.rfc3507.client.ICAPClient.execute(ICAPClient.java:94)
at net.rfc3507.client.Main.main(Main.java:24)
Caused by: java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
at java.net.SocketOutputStream.write(SocketOutputStream.java:143)
at net.rfc3507.client.ICAPClient.performAdaptation(ICAPClient.java:211)
at net.rfc3507.client.ICAPClient.execute(ICAPClient.java:92)
... 1 more

My Main-Method to use your library was:

    final String SERVER = "myserver";
    final int PORT = 1344;
    final String SERVICE = "AVSCAN";

    File files = new File("C:\\dev\\8473.PNG");
    System.out.println(files.toPath());

    ICAPClient icapClient = new ICAPClient(SERVER, PORT);
    ICAPRequest icapRequest = new ICAPRequest(SERVICE, ICAPRequest.Mode.REQMOD);
    //icapRequest.setHttpRequestBody(files);
    byte[] fileContent = Files.readAllBytes(files.toPath());
    icapRequest.setHttpRequestBody(fileContent);
    ICAPResponse icapResponse = icapClient.execute(icapRequest);
    System.out.println(icapResponse.toString());

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.