mirror of
https://github.com/foss42/apidash.git
synced 2025-05-31 14:23:45 +08:00
Merge branch 'main' into add-feature-checkbox
This commit is contained in:
@ -55,9 +55,12 @@ class DartHttpCodeGen {
|
||||
final strContent = CodeExpression(Code('r\'\'\'$body\'\'\''));
|
||||
dataExp = declareVar('body', type: refer('String')).assign(strContent);
|
||||
|
||||
final hasContentTypeHeader = composeHeaders.keys.any((k) => k.toLowerCase() == HttpHeaders.contentTypeHeader);
|
||||
if (!hasContentTypeHeader) {
|
||||
composeHeaders.putIfAbsent(HttpHeaders.contentTypeHeader,
|
||||
() => kContentTypeMap[contentType] ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
Expression? queryParamExp;
|
||||
List<Expression>? uriReassignExps;
|
||||
|
@ -105,7 +105,9 @@ print(data.decode("utf-8"))
|
||||
var headers = requestModel.enabledHeadersMap;
|
||||
if (headers.isNotEmpty || hasBody) {
|
||||
hasHeaders = true;
|
||||
if (hasBody) {
|
||||
bool hasContentTypeHeader = headers.keys.any((k) => k.toLowerCase() == HttpHeaders.contentTypeHeader);
|
||||
|
||||
if (hasBody && !hasContentTypeHeader) {
|
||||
headers[HttpHeaders.contentTypeHeader] =
|
||||
kContentTypeMap[requestModel.requestBodyContentType] ?? "";
|
||||
}
|
||||
|
@ -28,10 +28,13 @@ Future<(http.Response?, Duration?, String?)> request(
|
||||
if (contentLength > 0) {
|
||||
body = requestBody;
|
||||
headers[HttpHeaders.contentLengthHeader] = contentLength.toString();
|
||||
final hasContentTypeHeader = headers.keys.any((k) => k.toLowerCase() == HttpHeaders.contentTypeHeader);
|
||||
if (!hasContentTypeHeader) {
|
||||
headers[HttpHeaders.contentTypeHeader] =
|
||||
kContentTypeMap[requestModel.requestBodyContentType] ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
Stopwatch stopwatch = Stopwatch()..start();
|
||||
switch (requestModel.method) {
|
||||
case HTTPVerb.get:
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:apidash/consts.dart';
|
||||
import 'package:apidash/utils/utils.dart' show getValidRequestUri;
|
||||
import 'package:apidash/models/models.dart' show RequestModel;
|
||||
@ -133,7 +134,9 @@ Map<String, dynamic> requestModelToHARJsonRequest(
|
||||
var headers =
|
||||
useEnabled ? requestModel.enabledHeadersMap : requestModel.headersMap;
|
||||
if (headers.isNotEmpty || hasBody) {
|
||||
if (hasBody) {
|
||||
bool hasContentTypeHeader = headers.keys.any((k) => k.toLowerCase() == HttpHeaders.contentTypeHeader);
|
||||
|
||||
if (hasBody && !hasContentTypeHeader) {
|
||||
var m = {
|
||||
"name": "Content-Type",
|
||||
"value": kContentTypeMap[requestModel.requestBodyContentType] ?? ""
|
||||
|
@ -15,7 +15,8 @@ Map<String, String> headers = {
|
||||
"Indicates the encoding transformations that have been applied to the entity body of the response.",
|
||||
"Content-Security-Policy":
|
||||
"Controls the sources from which content can be loaded on a web page to mitigate various types of attacks.",
|
||||
"Content-Type": "Indicates the media type of the entity body.",
|
||||
"Content-Type":
|
||||
"Indicates the original media type of the resource (prior to any content encoding applied for sending)",
|
||||
"Cookie": "Used to send previously stored cookies back to the server.",
|
||||
"Cross-Origin-Embedder-Policy":
|
||||
"Controls whether a document is allowed to be embedded in another document.",
|
||||
|
Reference in New Issue
Block a user