KCDDB

httpsubmit.cpp
1 /*
2  SPDX-FileCopyrightText: 2002 Benjamin Meyer <[email protected]>
3  SPDX-FileCopyrightText: 2003 Richard Lärkäng <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #include "httpsubmit.h"
9 
10 #include <KIO/Job>
11 #include <QDebug>
12 
13 namespace KCDDB
14 {
15  HTTPSubmit::HTTPSubmit(const QString& from, const QString& hostname, uint port)
16  : Submit(), from_(from)
17  {
18  url_.setScheme( QLatin1String( "http" ));
19  url_.setHost(hostname);
20  url_.setPort(port);
21  url_.setPath(QLatin1String( "/~cddb/submit.cgi" ));
22  }
23 
24  HTTPSubmit::~HTTPSubmit()
25  {
26 
27  }
28 
29  KIO::Job* HTTPSubmit::createJob(const CDInfo& cdInfo)
30  {
31  KIO::TransferJob* job = KIO::http_post(url_, diskData_.toUtf8().data(), KIO::HideProgressInfo);
32 
33  job->addMetaData(QLatin1String( "content-type" ), QLatin1String( "Content-Type: text/plain" ));
34  QString header;
35 
36  header += QLatin1String( "Content-Type: text/plain\n" );
37 
38  header += QLatin1String( "Category: " ) + cdInfo.get(Category).toString() + QLatin1Char( '\n' );
39  header += QLatin1String( "Discid: " ) + cdInfo.get(QLatin1String( "discid" )).toString() + QLatin1Char( '\n' );
40  header += QLatin1String( "User-Email: " ) + from_ + QLatin1Char( '\n' );
41  //header += QLatin1String( "Submit-Mode: test\n" );
42  header += QLatin1String( "Submit-Mode: submit\n" );
43  header += QLatin1String( "Charset: UTF-8" );
44 
45  job->addMetaData(QLatin1String( "customHTTPHeader" ), header);
46 
47  return job;
48  }
49 }
void addMetaData(const QString &key, const QString &value)
KIOCORE_EXPORT TransferJob * http_post(const QUrl &url, QIODevice *device, qint64 size=-1, JobFlags flags=DefaultFlags)
HideProgressInfo
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 23:10:08 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.