问题描述
我有这个.NET核心API,我们对此给予了大力支持。因此,当我运行此API并使用Swagger UI对其进行测试时,它工作正常。对于否定的测试用例,它将返回正确的错误响应,即
Status : 0
Response body :nothing
这是我对Edge,Chrome和Postman的响应。
但是,当我在docker容器上运行相同的API时,Edge和Postman可以正常运行,但Chrome可以运行
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
struct node
{
int data;
int freq;
node *left;
node *right;
};
node *nodeData(int ch,int freq,node *l,node *r)
{
node *huffmanNode = new node();
huffmanNode->data = ch;
huffmanNode->freq = freq;
huffmanNode->left = l;
huffmanNode->right = r;
return huffmanNode;
}
class comp
{
public:
bool operator()(node *l,node *r)
{
return l->freq > r->freq;
}
};
//encoding funtion
void encodeChars(node *root,string str,unordered_map<int,string> &huffmancode)
{
if (root == nullptr)
return;
if (!root->left && !root->right)
huffmancode[root->data] = str;
encodeChars(root->left,str + "0",huffmancode);
encodeChars(root->right,str + "1",huffmancode);
}
void calc_freq(int image[6][6])
{
int arr[36];
unordered_map<int,int> mp;
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 6; j++)
{
static int k = 0;
arr[k] = image[i][j];
k++;
}
}
//making a priority queue
priority_queue<node *,vector<node *>,comp> pq;
//pushing the elements in the pq
for (auto pair : mp)
pq.push(nodeData(pair.first,pair.second,nullptr,nullptr));
//iterating till there is only 1 element left in the queue
while (pq.size() != 1)
{
node *left = pq.top();
pq.pop();
node *right = pq.top();
pq.pop();
int sum = left->freq + right->freq;
pq.push(nodeData('$',sum,left,right));
}
node *root = pq.top();
unordered_map<int,string> huffmanCode;
encodeChars(root,"",huffmanCode);
cout << "huffman codes are::" << endl;
for (auto pair : huffmanCode)
{
cout << pair.first << "-->" << pair.second << endl;
}
}
int main()
{
int image[6][6] = {
{1,2,3,4,5,6},{2,6,7},{0,4},{1,1,1},{4,7,1}};
calc_freq(image);
}
我与提琴手一起检查过,我的应用程序是否对chrome正确响应?但是API的响应是正确的,只是它没有显示在chrome中。
可能是什么原因?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)