network: Fix warning about freeing const string
The use of g_clear_pointer (&str, g_free) with str being a const gchar * caused warning errors.
Instead of using str for both constant and allocated strings use separate variables. Autofree the allocated strings.