我目前正在编写一个 HTTP 客户端来对返回 HTTP 响应的 URL 执行 HTTP POST。
但是,对于错误消息代码 400 和 500,它发送回非分块 HTTP 响应,对于成功消息 201,它发送分块响应。
在请求中,我设置了内容长度,所以我不确定为什么它仍然向我们发送分块传输编码。我可以在请求中设置任何其他标头,它会告诉 HTTP 服务器不要发送分块编码吗?
headerList.append("POST /v2/charges HTTP/1.1")
headerList.append("Content-Type: application/json")
headerList.append("host: xxxxxxxxx")
headerList.append("request-id: ABCD001123")
headerList.append("Content-length: %d" %len(Msg))
hostReqHeader = "\r\n".join(headerList)
reqData = hostReqHeader + '\r\n\r\n' + qbPosMsg
Run Code Online (Sandbox Code Playgroud)
我使用套接字来发送这些 HTTP 消息,而不是使用 httplib 或请求库。
我在控制台应用程序中使用wcout时发现了一个奇怪的问题.
在调用某个函数之后,其余的wcout调用根本不起作用.即输出语句没有出现在控制台上.
我注意到在函数中,我使用了一个从未分配的宽字符数组.
WCHAR wArray[1024];
wcout<<wArray<<endl;
Run Code Online (Sandbox Code Playgroud)
在这次电话会议之后,所有其他wcout都停止了工作.
所以,我只是想知道是什么让wcout与cout不同,以及为什么会出现这个问题,
我有一个测试存根,它将向系统日志写入几条日志消息。
但是,这个系统日志也会被许多其他应用程序更新。所以,基本上,我想做一个tail -f system.log | grep "application name"只获取适当的日志消息。
我在看 dbaez 生成器技巧,我正在尝试将http://www.dabeaz.com/generators/follow.py和http://www.dabeaz.com/generators/apachelog.py结合起来
所以,在我的__main__(),我有这样的事情:
try:
dosomeprocessing() #outputs stuff to the log file
Run Code Online (Sandbox Code Playgroud)
在 dosomeprocessing() 中,我运行一个循环,对于每个循环,我想查看是否有任何由我的应用程序引起的新日志消息,不一定将其打印出来,而是将它们存储在某处以进行一些验证。
logfile = open("/var/adm/messages","r")
loglines = follow(logfile)
logpats = r'I2G(JV)'
logpat = re.compile(logpats)
groups = (logpat.match(line) for line in loglines)
for g in groups:
if g:
print g.groups()
Run Code Online (Sandbox Code Playgroud)
日志看起来像:
Feb 4 12:55:27 Someprocessname.py I2G(JV)-300[20448]: [ID 702911 local2.error] [MSG-70047] xxxxxxxxxxxxxxxxxxxxxxx
Feb 4 12:55:27 Someprocessname.py I2G(JV)-300[20448]: [ID 702911 local2.error] [MSG-70055] xxxxxxxxxxxxxxxxxxxxxxx
Run Code Online (Sandbox Code Playgroud)
除了很多其他的gobblygook。 …
我正在使用Document对象从xml中提取所有标记.如果xml有一个空标记,我会得到一个空指针异常.我该如何防范这个?如何检查空标签?
<USTrade>
<CreditorId>
<CustomerNumber>xxxx</CustomerNumber>
<Name></Name>
<Industry code="FY" description="Factor"/>
</CreditorId>
<DateReported format="MM/CCYY">02/2012</DateReported>
<AccountNumber>54000</AccountNumber>
<HighCreditAmount>0000299</HighCreditAmount>
<BalanceAmount>0000069</BalanceAmount>
<PastDueAmount>0000069</PastDueAmount>
<PortfolioType code="O" description="Open Account (30, 60, or 90 day account)"/>
<Status code="5" description="120 Dys or More PDue"/>
<Narratives>
<Narrative code="GS" description="Medical"/>
<Narrative code="CZ" description="Collection Account"/>
</Narratives>
</USTrade>
<USTrade>
Run Code Online (Sandbox Code Playgroud)
所以,当我使用时:
NodeList nm = docElement.getElementsByTagName("Name");
if (nm.getLength() > 0)
name = nullIfBlank(((Element) nm.item(0))
.getFirstChild().getTextContent());
Run Code Online (Sandbox Code Playgroud)
Nodelist给出的长度为1,因为有一个标签,但是当我执行getTextContent()时,它会命中空指针,因为FirstChild()没有为tag = Name返回任何内容
而且,我已经为每个xml标签做了这个.在每次标记提取之前,我都可以进行简单的检查吗?
CREATE OR REPLACE VIEW USER_AUD_VIEW ("AUDIT_ID", "USER_ID", "TABLE_NAME_TXT", "COLUMN_NAME_TXT", "OLD_VALUE_TXT", "NEW_VALUE_TXT", "AUDIT_LAST_UPDATED_DT", "AUDIT_UPDATED_USER_ID", "EVALUATOR_ID", "PRODUCT_ID")
AS
SELECT acm.audit_id,
GET_TOKEN(GET_TOKEN(acm.PRIMARY_KEY_VALUES,1,','),2,':') AS user_id,
acm.table_name_txt,
acm.column_name_txt,
CASE
WHEN UPPER(acm.column_name_txt) = 'PASSWORD_TXT'
THEN '******'
ELSE acm.old_value_txt
END AS old_value_txt,
CASE
WHEN UPPER(acm.column_name_txt) = 'PASSWORD_TXT'
THEN '******'
ELSE acm.new_value_txt
END AS new_value_txt,
acm.audit_last_updated_dt,
CASE
WHEN UPPER(acm.audit_updated_user_id) = 'UNKNOWN'
THEN acm.audit_updated_user_id
ELSE (users.user_id
|| ' ('
|| DECODE(users.last_name_txt, NULL,' ' , users.last_name_txt)
|| ', '
|| DECODE(users.first_name_txt, NULL,'' , users.first_name_txt)
|| ')' )
END
AS audit_uupdated_user_id, …Run Code Online (Sandbox Code Playgroud) 我只是想知道在C++中是否允许这种类型的声明
static nextUnassignedTableID = 0;
static nextUnassignedFieldID = TSFID_MINIMUM_USER_TSFID;
Run Code Online (Sandbox Code Playgroud)
它不会在Solaris/AIX上抱怨任何内容.
但是,在Red Hat Enterprise Linux上,它抱怨道
TSIDConverter.cpp(637): error #303: explicit type is missing ("int" assumed)
static nextUnassignedTableID = 0;
TSIDConverter.cpp(638): error #303: explicit type is missing ("int" assumed)
static nextUnassignedFieldID = TSFID_MINIMUM_USER_TSFID;
Run Code Online (Sandbox Code Playgroud)
在Linux上,我使用Intel 11.1编译器和命令icpc -m32.
我是否应该包含其他库以使其成为编译器,还是不再允许这种声明风格?
我们碰巧使用IBM appscan http://www-01.ibm.com/software/awdtools/appscan/
针对我们的java代码库,它返回了大约3000个高严重性漏洞.
它们中的大多数碰巧是系统信息泄漏,它认为当我们在catch块中打印堆栈跟踪时会发生这种情况,但是我们只打印它正在发生的文件名和行号,这使我们能够更好地调试代码.
还有一些是关于SQL注入,输入验证等.
但是,我的问题是关于资源耗尽(文件描述符,磁盘空间,套接字......),它列出java.io.BufferedReader.readLine了可能的外部攻击的所有实例.
InputStream ins=conn.getInputStream();
String inputLine;
if (!preserveLinefeeds) {
BufferedReader in = new BufferedReader(new InputStreamReader(ins));
while ((inputLine = in.readLine()) != null)
pr.readThreadResponse+=inputLine;
in.close();
ins.close();
}
Run Code Online (Sandbox Code Playgroud)
conn是一个HttpURLConnection对象.
如何在代码中添加safegaurds来防止这种情况?
这可能太本地化了,但我希望有人可以帮我正确地表达我的问题.
因此,我们有一个前端Web服务器,使用CORBA与后端应用服务器通信.我被要求将后端应用程序移植到LINUX盒子,我做了.但是,为了测试它,我试图将前端Web服务器指向LINUX后端.
我们正在使用omniORB-4.1.4,以下是如何获得后端系统的实例:
String args[] = new String[0];
System.out.println(getDateTime()+"Instance: Connecting to: "+initialHost+" "+initialPort+" "+enviornment+" "+version);
java.util.Properties props = new java.util.Properties();
props.put("org.omg.CORBA.ORBInitialPort", initialPort);
props.put("org.omg.CORBA.ORBInitialHost", initialHost);
props.put("com.sun.CORBA.giop.ORBGIOPVersion", "1.0");
orb=org.omg.CORBA.ORB.init(args,props);
Run Code Online (Sandbox Code Playgroud)
如果前端和后端都在SUN/Solaris机箱上运行,那么它似乎可以正常运行.但是,当后端在LINUX盒上运行时,它会发出Connection Refused异常,主机名为127.0.0.1
2012/10/22 13:53:22.033 EvaluateInstance: Connecting to: cmrheldv 23026 DEV87 0871
Oct 22, 2012 1:53:22 PM com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: cmrheldv; port: 23026"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2200)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2221)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:205)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:218)
at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:101)
at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:171)
at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:118)
at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.invoke(BootstrapResolverImpl.java:74) …Run Code Online (Sandbox Code Playgroud) 由于缺乏信息,我发布的早期问题已经结束.
如果我在这里遗漏了什么,请告诉我.变换器似乎是将文件:/添加到文件路径的开头.
我在Solaris环境中工作,以下是应用转换时会发生的情况:
DOMSource sourcexml = new DOMSource(doc);
StreamResult resultxml = new StreamResult(new File("file.xml"));
transformer.transform(sourcexml, resultxml);
Run Code Online (Sandbox Code Playgroud)
我得到的例外是:
javax.xml.transform.TransformerException: java.io.FileNotFoundException: file:/opt/origenate/or_dev87/apps/documentarchive/file.xml (No such file or directory)
Run Code Online (Sandbox Code Playgroud)
注意,该文件存在于/opt/origenate/or_dev87/apps/documentarchive/file.xml中,但变换器对象正在查找文件:/opt/origenate/or_dev87/apps/documentarchive/file.xml.
为什么要附加文件:/?无论如何我可以删除它吗?
在for循环中有一个CreateThread()调用,我希望所有的线程一个接一个地启动,每个线程将数据写入一个对象.
`$while (ii != mapOServs.end())
{
Array_of_Thread_Handles[i] = CreateThread(NULL,0,MyThread, &args[i] , 0 , NULL);
}
Run Code Online (Sandbox Code Playgroud)
但是线程在遇到WaitForMultipleObjects或WaitForSingleObject之前不会启动.
如何让所有线程一个接一个地运行而不等待响应?
此外,最好的对象是什么,以便它可以同时由不同的线程修改.