KCDDB

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

KDE's Doxygen guidelines are available online.