<commit_before>/* libquvi
 * Copyright (C) 2013  <NAME> <<EMAIL>>
 *
 * This file is part of libquvi <http://quvi.sourceforge.net/>
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public
 * License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General
 * Public License along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

#include "config.h"

#include <curl/curl.h>
#include <glib.h>

#include "quvi.h"
/* -- */
#include "_quvi_s.h"

glong c_reset_headers(_quvi_t q)
{
  CURLcode cc;
  CURL *c;

  c = q->handle.curl;
  cc = curl_easy_setopt(c, CURLOPT_HTTPHEADER, NULL); /* clear custom headers */

  curl_slist_free_all(q->http.headers);
  q->http.headers = NULL;

  return (cc);
}

gint c_reset(_quvi_t q)
{
  CURL *c = q->handle.curl;

#ifdef _1
  /*
   * If a program re-using the libquvi's curl session handle sets the
   * CURLOPT_USERAGENT (or other options), the value would be lost.
   */
  curl_easy_reset(c);
#endif
  c_reset_headers(q);

  curl_easy_setopt(c, CURLOPT_USERAGENT, "Mozilla/5.0");
  curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(c, CURLOPT_COOKIELIST, "ALL"); /* clear, enable cookies */
#ifdef _1 /* Use whatever libcurl defaults to. */
  curl_easy_setopt(c, CURLOPT_MAXREDIRS, 5L); /* http://is.gd/kFsvE4 */
#endif
  curl_easy_setopt(c, CURLOPT_NOBODY, 0L);
<commit_msg>c_reset: Use either default or QUVI_OPTION_USER_AGENT value<commit_after>/* libquvi
 * Copyright (C) 2013  <NAME> <<EMAIL>>
 *
 * This file is part of libquvi <http://quvi.sourceforge.net/>
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public
 * License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General
 * Public License along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

#include "config.h"

#include <curl/curl.h>
#include <glib.h>

#include "quvi.h"
/* -- */
#include "_quvi_s.h"

glong c_reset_headers(_quvi_t q)
{
  CURLcode cc;
  CURL *c;

  c = q->handle.curl;
  cc = curl_easy_setopt(c, CURLOPT_HTTPHEADER, NULL); /* clear custom headers */

  curl_slist_free_all(q->http.headers);
  q->http.headers = NULL;

  return (cc);
}

gint c_reset(_quvi_t q)
{
  CURL *c = q->handle.curl;

#ifdef _1
  /*
   * If a program re-using the libquvi's curl session handle sets the
   * CURLOPT_USERAGENT (or other options), the value would be lost.
   */
  curl_easy_reset(c);
#endif
  c_reset_headers(q);

  curl_easy_setopt(c, CURLOPT_USERAGENT, (q->opt.user_agent->len >0)
                   ? q->opt.user_agent->str
                   : "Mozilla/5.0");

  curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(c, CURLOPT_COOKIELIST, "ALL"); /* clear, enable cookies */
#ifdef _1 /* Use whatever libcurl defaults to. */
  curl_easy_setopt(c, CURLOPT_MAXREDIRS, 5L); /* http://is.gd/kFsvE4 */
#endif
  curl_easy_setopt(c, CURLOPT_NOBODY, 0L);

{'fraction_non_alphanumeric': 0.11442256519425226, 'fraction_numerical': 0.007184672698243746, 'mean_word_length': 3.6811955168119552, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6671246', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1291, 'n_words': 419}