Add PHP Debugging header toggle to client/globals

This commit is contained in:
Hank Grabowski 2023-03-20 09:58:02 -04:00
parent 2130e67c7f
commit 2d752bb0d9
2 changed files with 15 additions and 17 deletions

View file

@ -552,6 +552,9 @@ class RemoteFileClient extends FriendicaClient {
final postUri = Uri.parse('https://$serverName/api/friendica/photo/create');
final request = http.MultipartRequest('POST', postUri);
request.headers['Authorization'] = _profile.credentials.authHeaderValue;
if (usePhpDebugging) {
request.headers['Cookie'] = 'XDEBUG_SESSION=PHPSTORM;path=/';
}
request.fields['desc'] = description;
request.fields['album'] = album;
request.files.add(await http.MultipartFile.fromBytes(
@ -645,7 +648,6 @@ class StatusesClient extends FriendicaClient {
final url = Uri.parse('https://$serverName/api/v1/statuses');
final body = {
'status': text,
'visibility': 'public',
if (spoilerText.isNotEmpty) 'spoiler_text': spoilerText,
if (inReplyToId.isNotEmpty) 'in_reply_to_id': inReplyToId,
if (mediaIds.isNotEmpty) 'media_ids': mediaIds,
@ -839,10 +841,7 @@ abstract class FriendicaClient {
try {
final response = await http.get(
url,
headers: {
'Authorization': _profile.credentials.authHeaderValue,
'Content-Type': 'application/json; charset=UTF-8'
},
headers: _header,
);
if (response.statusCode != 200) {
@ -866,10 +865,7 @@ abstract class FriendicaClient {
try {
final response = await http.post(
url,
headers: {
'Authorization': _profile.credentials.authHeaderValue,
'Content-Type': 'application/json; charset=UTF-8'
},
headers: _header,
body: jsonEncode(body),
);
@ -891,10 +887,7 @@ abstract class FriendicaClient {
try {
final response = await http.put(
url,
headers: {
'Authorization': _profile.credentials.authHeaderValue,
'Content-Type': 'application/json; charset=UTF-8'
},
headers: _header,
body: jsonEncode(body),
);
@ -916,10 +909,7 @@ abstract class FriendicaClient {
try {
final response = await http.delete(
url,
headers: {
'Authorization': _profile.credentials.authHeaderValue,
'Content-Type': 'application/json; charset=UTF-8'
},
headers: _header,
body: jsonEncode(body),
);
@ -950,4 +940,10 @@ abstract class FriendicaClient {
))
.execErrorCastAsync();
}
Map<String, String> get _header => {
'Authorization': _profile.credentials.authHeaderValue,
'Content-Type': 'application/json; charset=UTF-8',
if (usePhpDebugging) 'Cookie': 'XDEBUG_SESSION=PHPSTORM;path=/',
};
}

View file

@ -15,6 +15,8 @@ final useImagePicker = kIsWeb || Platform.isAndroid || Platform.isIOS;
final useVideoPlayer = kIsWeb || Platform.isAndroid || Platform.isIOS;
final usePhpDebugging = true;
Future<bool?> showConfirmDialog(BuildContext context, String caption) {
return showDialog<bool>(
context: context,