Add various HTTP headers in the outgoing requests

pull/1/head
Grégory Oestreicher 2016-12-18 11:14:41 +01:00
parent 35cd1f8723
commit f1b45f320a
2 changed files with 10 additions and 0 deletions

View File

@ -344,6 +344,8 @@ function syncDeletedArticles( timerSource, props, cb )
http.open( "GET", url, true );
http.setRequestHeader( "Authorization:", "Bearer " + props.token );
http.setRequestHeader( "Accept", "application/json" );
http.setRequestHeader( "Connection", "close" );
http.send();
}
@ -581,6 +583,8 @@ function _downloadNextArticles( url, token, page, cb )
http.open( "GET", pageUrl, true );
http.setRequestHeader( "Authorization:", "Bearer " + token );
http.setRequestHeader( "Accept", "application/json" );
http.setRequestHeader( "Connection", "close" );
http.send();
}

View File

@ -52,6 +52,10 @@ void HttpPatchRequest::start()
QNetworkRequest rq( mUrl );
rq.setRawHeader( QByteArray( "Authorization" ), authHeader );
rq.setRawHeader( QByteArray( "Accept" ), QByteArray( "application/json" ) );
rq.setHeader( QNetworkRequest::ContentLengthHeader, mContent.length() );
rq.setHeader( QNetworkRequest::ContentTypeHeader, QStringLiteral( "application/json" ) );
rq.setRawHeader( QByteArray( "Connection" ), QByteArray( "close" ) );
mReply = mQnam.sendCustomRequest( rq, QByteArray( "PATCH" ), mContentIO );
connect( mReply, &QNetworkReply::finished, this, &HttpPatchRequest::onRequestDone );
@ -92,6 +96,8 @@ void HttpDeleteRequest::start()
QNetworkRequest rq( mUrl );
rq.setRawHeader( QByteArray( "Authorization" ), authHeader );
rq.setRawHeader( QByteArray( "Accept" ), QByteArray( "application/json" ) );
rq.setRawHeader( QByteArray( "Connection" ), QByteArray( "close" ) );
mReply = mQnam.sendCustomRequest( rq, QByteArray( "DELETE" ) );
connect( mReply, &QNetworkReply::finished, this, &HttpDeleteRequest::onRequestDone );