Transfer Accelerator Plugin HTTP header compatibility

Hi Author,
I’ve been using transfer for a while and already studied source code carefully. I am going to integrate my external application with this plugin. I have few comments as:
1/ Using PUSH mode when the client sends an initial message to API : POST /transfers/push . The body is pure json message, but the request header is missing “Content-Type” : “application/json”. I think some rest framework like SPRING Framework is not accepting the request if this header is missing. So I recommend to add header “Content-Type”: “application/json” to below

class PushJob::CreateTransactionState : public IState
  {
  private:
  [...]

  public:
    CreateTransactionState(const PushJob& job,
                           JobInfo& info) :
      job_(job),
      info_(info)
    {
      [...]
    }

    virtual StateUpdate* Step()
    {
      Json::Value answer;
      std::map<std::string, std::string> headers;
      job_.query_.GetHttpHeaders(headers);
      
     headers["Content-Type"] = "application/json";

2/ The next message client sends to server when it sends the bucket by the route “/transfers/send/{transactionId}/{bucketId}”, it also lacks header : “Content-Type” : “application/octet-stream”. So I recommend with below code:

class PushJob::PushBucketsState : public IState
  {
  private:
  [...]  
  public:
    PushBucketsState(const PushJob&  job,
                     JobInfo& info,
                     const std::string& transactionUri,
                     const std::vector<TransferBucket>& buckets) :
      job_(job),
      info_(info),
      transactionUri_(transactionUri)
    {
      std::map<std::string, std::string> headers;
      job_.query_.GetHttpHeaders(headers);

      headers["Content-Type"] = "application/octet-stream";

Although those tiny changes does not affect at all to the Orthanc. But to be http standard compatible, and to make third-party can integrate with Transfer Plugin Client, would you like to review my recommendations and patch them if you think it’s necessary.

Thanks
Christophe

Adding more headers to Configuration.json file according to this book : REST API of Orthanc — Orthanc Book documentation resolves my issue. Sorry and ignore my post

1 Like

Hi @Christophe

Although you have found a workaround, I have implemented your suggestions to make the plugin more HTTP compliant.

Thanks !

Alain.

1 Like