added contentHash

This commit is contained in:
Clemens 2016-07-25 10:56:12 +02:00
parent 0aedea6e60
commit 61ef7ca91b
3 changed files with 10 additions and 6 deletions

View File

@ -5,6 +5,8 @@ import json
import logging
import os.path
import re
import hashlib
import six
import tornado.websocket
@ -46,6 +48,7 @@ def convert_flow_to_json_dict(flow):
"http_version": flow.request.http_version,
"headers": tuple(flow.request.headers.items(True)),
"contentLength": len(flow.request.content) if flow.request.content is not None else None,
"contentHash": hashlib.sha256(flow.request.raw_content).hexdigest() if flow.request.content is not None else None,
"timestamp_start": flow.request.timestamp_start,
"timestamp_end": flow.request.timestamp_end,
"is_replay": flow.request.is_replay,
@ -57,6 +60,7 @@ def convert_flow_to_json_dict(flow):
"reason": flow.response.reason,
"headers": tuple(flow.response.headers.items(True)),
"contentLength": len(flow.response.content) if flow.response.content is not None else None,
"contentHash": hashlib.sha256(flow.response.raw_content).hexdigest() if flow.response.content is not None else None,
"timestamp_start": flow.response.timestamp_start,
"timestamp_end": flow.response.timestamp_end,
"is_replay": flow.response.is_replay,
@ -295,10 +299,11 @@ class ReplayFlow(RequestHandler):
class FlowContent(RequestHandler):
def post(self, flow_id, message):
self.flow.backup()
message = getattr(self.flow, message)
flow = self.flow
flow.backup()
message = getattr(flow, message)
message.content = self.request.files.values()[0][0].body
self.state.update_flow(self.flow)
self.state.update_flow(flow)
def get(self, flow_id, message):
message = getattr(self.flow, message)

View File

@ -46,7 +46,7 @@ export default class ContentLoader extends Component {
}
componentWillReceiveProps(nextProps) {
let reload = nextProps.message !== this.props.message || nextProps.lastFileUpload !== this.props.lastFileUpload
let reload = nextProps.message !== this.props.message
let isUserEdit = !nextProps.readonly && nextProps.message.content
if (isUserEdit)

View File

@ -114,7 +114,6 @@ export function update(flow, data) {
export function uploadContent(flow, file, type) {
const body = new FormData()
if (typeof file !== File)
file = new Blob([file], {type: 'plain/text'})
body.append('file', file)
return dispatch => fetchApi(`/flows/${flow.id}/${type}/content`, {method: 'post', body} )